write a program that presents to the users a choice of your 4 favorite beverages (water, milk, juice and coffee) 2)Then allows the user to choose a beverage by chose. Use switch display the choice, 3)modify the program so that if the user enters a choice other than 1,2,3 and 4 then it will output "invalid choice" 4) modify your program to make the user enter a quantity of the chosen drink. If the user enters quantity outside of the range [1,5] then the program will output "invalid quantity" knowing that drink prices are respectively: 1 $, 1.5 $, 2$ and 1.7 $ print the total amount that the user should pay. 5) modify your program to ask the user to enter the amount of money first. 6) then they makes their choice and quantity. 7) if the money entered is less than the total amount, print " you can't buy this quantity of the chosen drink" otherwise, print the total amount and the remaining money.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

((Java code))1) write a program that presents to the users a choice of your 4 favorite beverages (water, milk, juice and coffee)

2)Then allows the user to choose a beverage by chose. Use switch display the choice,

3)modify the program so that if the user enters a choice other than 1,2,3 and 4 then it will output "invalid choice"

4) modify your program to make the user enter a quantity of the chosen drink. If the user enters quantity outside of the range [1,5] then the program will output "invalid quantity" knowing that drink prices are respectively: 1 $, 1.5 $, 2$ and 1.7 $ print the total amount that the user should pay.

5) modify your program to ask the user to enter the amount of money first.

6) then they makes their choice and quantity.

7) if the money entered is less than the total amount, print " you can't buy this quantity of the chosen drink" otherwise, print the total amount and the remaining money.

thank you 

Part 1:
Write a Java program that presents to the users a choice of your 4 favorite beverages
(Water, Milk, Juice, and Coffee).
• Then allow the user to choose a beverage by entering a number from 1 to 4.
• Output the name of which beverage they chose. Use switch to display the choice.
• Modify the program so that if the user enters a choice other than 1,2,3, and 4 then it will
output "Invalid choice."
Part 2:
Modify your program to make the user enter a quantity of the chosen drink. If the user
enters quantity outside of the range [1,5] then the program will output "Invalid
quantity."
Knowing that drink prices are respectively: 1 SAR, 1.5 SAR, 2 SAR, and 1.75 SAR,
print the total amount that the user should pay.
Part 3:
Modify your program to ask the user to enter the amount of money first.
• Then he makes his choice and quantity.
If the money entered is less than the total amount, print “You cannot buy this quantity
of the chosen drink" otherwise, print the total amount and the remaining money.
Transcribed Image Text:Part 1: Write a Java program that presents to the users a choice of your 4 favorite beverages (Water, Milk, Juice, and Coffee). • Then allow the user to choose a beverage by entering a number from 1 to 4. • Output the name of which beverage they chose. Use switch to display the choice. • Modify the program so that if the user enters a choice other than 1,2,3, and 4 then it will output "Invalid choice." Part 2: Modify your program to make the user enter a quantity of the chosen drink. If the user enters quantity outside of the range [1,5] then the program will output "Invalid quantity." Knowing that drink prices are respectively: 1 SAR, 1.5 SAR, 2 SAR, and 1.75 SAR, print the total amount that the user should pay. Part 3: Modify your program to ask the user to enter the amount of money first. • Then he makes his choice and quantity. If the money entered is less than the total amount, print “You cannot buy this quantity of the chosen drink" otherwise, print the total amount and the remaining money.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 8 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education