Created
March 10, 2015 11:05
-
-
Save anagri/415dcbed75754547df51 to your computer and use it in GitHub Desktop.
Prob1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shankara.bill; | |
public class Bill { | |
public static void main(String[] args) { | |
int[] prices = {1, 2, 3, 4}; | |
int[] quantities = {10, 5, 10, 5}; | |
String[] names = new String[]{"Quaker", "Kellogs", "Chocos", "Milk"}; | |
System.out.println("Name\t\tPrice\tQty\t\tTotal"); | |
int grandTotal = 0; | |
for (int i = 0; i < names.length; i++) { | |
String name = names[i]; | |
int total = prices[i] * quantities[i]; | |
System.out.println(String.format("%s\t\t%d\t\t%d\t\t%d", name, prices[i], quantities[i], total)); | |
grandTotal += total; | |
} | |
System.out.println(String.format("Grand Total\t\t\t\t\t%d", grandTotal)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment