Question
A candy shop sells only 7 different candies as follows: Candy 1, $1.98, Candy 2, $1.5, Candy 3, $3.25, Candy 4, 2.98, Candy 5, $7.88,
A candy shop sells only 7 different candies as follows: Candy 1, $1.98, Candy 2, $1.5, Candy 3, $3.25, Candy 4, 2.98, Candy 5, $7.88, Candy 6, $4.5, and Candy 7, $9.25. Create a java program for this candy shop. It should ask user which candy to purchase and the quantity of that kind candy. The program should display all candies user purchased and total quantiities and total prices user should pay.
You are rquired to use a switch statement to determine the price for each candy user purchased and use a sentinel-controlled loop to determine when the program should stop looping and display the final results.
Here is a sample ourput for reference: (The bolded 1, 2, 7, and 0 are entered by user when the program runs)
******* Sweet Candies *******
Candy 1 $1.98
Candy 2 $1.5
Candy 3 $3.25
Candy 4 $2.98
Candy 5 $7.88
Candy 6 $4.5
Candy 7 $9.25
***************************
Enter 1-7 to buy that candy or Enter 0 to Check Out:
1 How many Candy 1 you want to buy: 2
Candy 1 X 2 $3.96
Enter 1-7 to buy that candy or Enter 0 to Check Out: 7
How many Candy 7 you want to buy: 1
Candy 7 X 1 $9.25
Enter 1-7 to buy that candy or Enter 0 to Check Out: 0
************Receipt*****************
Total Candies: 3
Total Charge: $13.21
***********************************
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