Question: Your task is to write a program that will calculate the total bill of a customer after purchasing 3 items from the grocery store. This
Your task is to write a program that will calculate the total bill of a customer after purchasing 3 items from the grocery store. This assignment builds on 2 key concepts from the last assignment
1. Unlike your last assignment , this time the name, quantity and cost per unit item must be input from the user, instead of being hardcoded. You must also input the sales tax from the user. Once you have input the items from the user and stored them into appropriate variables, the actual calculation is similar to the last assignment.
2. Your program must display a table consisting of
A) Name of the item
B) Cost per unit
C) Quantity
for each item. At the end of this table, you should display a line with the total sales tax, and a line displaying the total bill amount. All number MUST be rounded upto 2 decimal places.
SAMPLE INPUT/OUTPUT
Enter name of item : Apples
Enter cost per unit of item : 0.57
Enter quantity of item : 5
Enter name of item : Milk
Enter cost per unit of item : 1.89
Enter quantity of item : 4
Enter name of item : Chicken
Enter cost per unit of item : 2.49
Enter quantity of item : 5.67
Enter Sales tax (%); 0.06
Item Quantity Cost
---------------------------------------
Apples 5.00 0.57
Milk 4.00 1.89
Chicken 5.67 2.49
Sales tax : $1.47
---------------------------------------
Total Bill : $26.00
---------------------------------------
Hints
1. You should have 3 new variables of type "String" to store the name of the items (in addition to the variables you used last time).
2. Think about how to output the data in the table. (System.out.format) . All numbers should be rounded upto 2 decimal places.
3. You may assume the item name will not exceed 10 characters, and any number/fraction that you input will not exceed 10 digits, including the decimal part.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
