Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Krunchy Krabcakes is a seafood restaurant which serves a very limited menu of sea-based delicacies. The menu consists of the following items with associated prices:

Krunchy Krabcakes is a seafood restaurant which serves a very limited menu of sea-based delicacies. The menu consists of the following items with associated prices:

Crabcake $4.59 Shrimp Wrap $7.79 Lobster Soup $9.39

Write a Java program which displays a menu to the customer which allows them to place an order consisting of one or more of these menu items. The menu should use a simple numeric selection method to order an item. For example, '1' orders a crabcake, '2' orders an shrimp wrap, and '3' is an order of lobster soup, 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 for their order.

Your program must use a while loop to allow the customer to order multiple items (and complete their order by pressing 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. User input should be read as an integer (not a String or char).

Refer to the programming rubric for details on how this project will be graded. 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. You should use named constants with upper case names for your menu prices since those values will not change, for example you can declare the price of a crabcake as

final double PRICE_CRABCAKE = 4.59;

The menu numbers associated with ordering an item or completing an order should also be declared (and used) as named constants.

Sample Input/Output (user input is shown in red):

Welcome to Krunchy Krabcakes! Please enter an item to order, or 0 to complete your order. Enter 1 to order a crab cake for $4.59 Enter 2 to order an shrimp wrap for $7.79 Enter 3 to order lobster soup for $9.39 Order: 1 You have ordered a total of 1 crab cake(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order a crab cake for $4.59 Enter 2 to order an shrimp wrap for $7.79 Enter 3 to order lobster soup for $9.39 Order: 1 You have ordered a total of 2 crab cake(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order a crab cake for $4.59 Enter 2 to order an shrimp wrap for $7.79 Enter 3 to order lobster soup for $9.39 Order: 2 You have ordered a total of 1 shrimp wrap(s) Please enter an item to order, or 0 to complete your order. Enter 1 to order a crab cake for $4.59 Enter 2 to order an shrimp wrap for $7.79 Enter 3 to order lobster soup for $9.39 Order: 3 You have ordered a total of 1 order(s) of lobster soup Please enter an item to order, or 0 to complete your order. Enter 1 to order a crab cake for $4.59 Enter 2 to order an shrimp wrap for $7.79 Enter 3 to order lobster soup for $9.39 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 a crab cake for $4.59 Enter 2 to order an shrimp wrap for $7.79 Enter 3 to order lobster soup for $9.39 Order: 0 Your order is complete! You have ordered 2 crab cakes 1 shrimp wraps 1 order(s) of lobster soup Your total cost is $26.36

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions