Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

Choose an appropriate organizational pattern for your speech

Answered: 1 week ago

Question

Writing a Strong Conclusion

Answered: 1 week ago