Question
Programming language: Java Write a menu driven program that will obtain user choices and calculate the total price of all items purchased. In the main
Programming language: Java
Write a menu driven program that will obtain user choices and calculate the total price of all items purchased.
In the main method, the user is asked to pick from any one of the options:
1.Entre
2.Drink
3.quit
if the user picks a choice of 1, ask the user to provide number of plates and then call the method getEntreePrice.
If the user picks a choice of 2, ask the user to provide the number of glasses and type of drink, call the method getDrinkPrice.
If the user picks a choice of 3, quit the loop
The program will loop several times and users can keep making choices to buy either entre or drinks, until the user picks a choice of 3.
During each loop, the totalPrice is updated. When the program quits the loop print the total price of entre and/or drinks purchased till then.
The methods requirements are as follows:
getEntreePrice takes as the parameter, the value of number of plates from the user. The getEntreePrice calculates and return the total price of entre. An plate of entre costs $12.00 and total price of entree = price of a plate times the number of plates
getDrinkPrice takes two parameters: number of drinks and type of drink. Number of drink is an integer and type of drink is a string with two possible values, hot or cold. The getDrinkPrice method calculates and returns the total price of drink as follows: if the drink type is hot, then unit price of drink is $2.50 per drink, else if the drink type is cold then the unit price is $1:50 per drink. Total drink price is number of drinks times the unit price per drink.
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