/
Billing.java
43 lines (40 loc) · 1.19 KB
/
Billing.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
package com.codefortomorrow.beginner.chapter9.practice;
/*
* Create a program called Billing which
* prompts the user for the number of items
* they will enter. Then ask the user for
* the name of the item and price repeatedly.
* Once the last item and its price has been
* entered, print a receipt which has each item
* and its price, as well as the subtotal, tax,
* and total. (The sales tax rate is 8%.)
* Hint: Use an array to store the item names and prices.
*
* Sample output:
* Enter the number of items: 3
* Enter item #1: shirt
* Enter price of item #1: $15.43
* Enter item #2: pants
* Enter price of item #2: $12.38
* Enter item #3: hat
* Enter price of item #3: $4.99
*
* RECEIPT
* --------------------------------------
* shirt - $15.43
* pants - $12.38
* hat - $4.99
* --------------------------------------
* Subtotal: $32.80
* Tax: $2.62
* Total: $35.42
*
* Hint: You may encounter a problem when using Scanner.
* Read the following article for a solution:
* https://www.geeksforgeeks.org/why-is-scanner-skipping-nextline-after-use-of-other-next-functions/
*/
public class Billing {
public static void main(String[] args) {
// write code here
}
}