Question
A local grocery store has four types of foods. A customer/user purchased a certain amount of each type of food at the following prices: Milk
A local grocery store has four types of foods. A customer/user purchased a certain amount of each type of food at the following prices: Milk - $1.19 per Litre (L) Cheese - $2.22 per Kilogram (Kg)
Beef - $3.12 per Kilogram (Kg) Kiwis - $4.66 per Kilogram (Kg)
They also paid tax on these items. Tax is currently 13%. The amount bought is given by the user by using the Scanner object (see programs in the PPT slides Chapter1 and Chapter2, of how to enable the user to give his/her input).
You are being asked to generate a receipt by creating a JAVA program that displays the output in the following format:
If the user (for example) buys 4L of milk, 3Kg of cheese, 2Kg of beef and 3 kg of kiwis, then the output will be displayed as follows:
Receipt: YOUR NAME HERE
Item | Unit Price | Quantity | Total Price |
Milk | 1.19 | 4L | 5.4 |
Cheese | 2.22 | 3Kg | 7.5 |
Beef | 3.12 | 2Kg | 7.1 |
Kiwis | 4.66 | 3Kg | 15.8 |
Total | 35.8 | ||
Format the output of the price with only one decimal.
Guidelines:
The class must be named Homework1.
You are expected to use variables to store and display the item labels (food names), item prices, and quantity of items purchased. Remember that you cannot buy part of an item, and you must pick your variable type accordingly.
You are expected to use a constant (Final) to store the tax value and use it in calculations. Note: Total price of the item = price * quantity purchased * Tax
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started