-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlooping5.java
40 lines (31 loc) · 1.12 KB
/
looping5.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
import hsa.*;
public class looping5{
public static void main(String[] args){
Console con = new Console();
int intCounter;
double dblTotal;
double dblSubtotal;
double dblTax;
double dblPrice;
int intItems;
//Creating a cashier program for walmart
dblTotal = 0;
dblSubtotal = 0;
dblTax = 0;
dblPrice = 0;
intItems = 0;
con.println("welcome to the walmart cashier checkout program");
con.println("how many items do you want to checktout");
intItems = con.readInt();
for(intCounter = 1; intCounter <= intItems; intCounter++){
con.println("Give me the price for item:"+intCounter);
dblPrice = con.readDouble();
dblSubtotal = dblSubtotal + dblPrice;
con.println("The current subtotal is:"+dblSubtotal);
}
dblTax = dblSubtotal * 0.13;
dblTotal = dblSubtotal + dblTax;
con.println("Your tax is:"+dblTax);
con.println("Your final total is:"+dblTotal);
}
}