-
Notifications
You must be signed in to change notification settings - Fork 0
/
BillGenerator.java
47 lines (34 loc) · 1.39 KB
/
BillGenerator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.Scanner;
public class BillGenerator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String[] s = new String[] { "idly Sambar", "Wada Samber", "dosa ", "Poori Bhaji", "Paratha",
"Vada Pao", "Misal ", "tea ", "coffee", "Total " };
int[] rate = new int[] { 30, 35, 40, 30, 25, 15, 100, 10, 15, 0 };
int[] qt = new int[10];
int sum = 0;
boolean quit = true;
do {
System.out.println("ITEM" + "\t\t\tPRICE");
for (int i = 0; i < 10; i++)
System.out.println((i + 1) + "." + s[i] + "\t\t" + rate[i]);
int ch = input.nextInt();
if (ch > 0 && ch < 10) {
System.out.println("enter the no of quantites of " + s[ch - 1]);
int q = input.nextInt();
qt[ch - 1] += q;
} else {
quit = false;
}
} while (quit);
System.out.println("Your Orders are:\n");
for (int i = 0; i < 10; i++) {
if (qt[i] != 0) {
sum += qt[i] * rate[i];
System.out.println(s[i] + "*" + qt[i] + " = " + qt[i] * rate[i] + "Rs");
}
}
System.out.println("Your total bill=" + sum);
System.out.println("Thank you !! ");
}
}