Question
Babette's Bistro is a restaurant which sells delicious French bistro fare, although with a very limited selection. The menu consists of the following items with
Babette's Bistro is a restaurant which sells delicious French bistro fare, although with a very limited selection. The menu consists of the following items with associated prices:
Braised Rabbit $8.89 Crispy Duck $7.99 Grilled Steak $10.57
Write a Java program which displays a menu to the customer which allows them to place an order consisting of one or more items. The menu should use a simple numeric selection method to order an item. For example, '1' orders braised rabbit, '2' orders crispy duck, and '3' orders grilled steak, while '0' indicates the order is complete. To order more than one of an item, the customer selects the item again on the menu. Once a customer's order is complete, your program should display the total number of each item ordered and the total price overall for their order.
Your program must use a do-while loop to allow the customer to order multiple items (and complete their order by selecting 0), and it must use a switch statement to handle each possible type of input, as well as displaying an error message if an incorrect choice is selected. Include break statements for each case in your switch (including the default case). User input should be read as an integer (not a String or char).
Remember to use consistent alignment and indentation, an identification header, and descriptive comments in your code (but don't overdo it). All user-facing output (i.e. prompts) must be spell-checked and proofread for correctness. Use named constants with upper case names for your menu prices, menu options, and repeated strings since those values will not change, for example declare the price of the braised rabbit as
final double PRICE_RABBIT = 8.89;
Do not write custom methods or use other Java language features in your program that have not been covered in class yet.
Remember to use a do-while loop! 10 points will be deducted if you use a while loop or for loop instead.
Expected Output (user input is shown in red)
Welcome to Babette's Bistro! Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 1 You have ordered a total of 1 rabbits(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 1 You have ordered a total of 2 rabbits(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 2 You have ordered a total of 1 ducks(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 3 You have ordered a total of 1 steaks(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 0 0 You have ordered 2 order(s) of rabbit 1 order(s) of duck 1 order(s) of steak Your total cost is $36.34
Invalid Input Example:
Welcome to Babette's Bistro! Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 4 Please enter a valid choice between 0 and 3 Please enter an item to order, or 0 to complete your order. Enter 1 to order braised rabbit for $8.89 Enter 2 to order crispy duck for $7.99 Enter 3 to order grilled steak for $10.57 Order: 0 0 You have ordered 0 order(s) of rabbit 0 order(s) of duck 0 order(s) of steak Your total cost is $0.00
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