Phase 1

Use if statements (including if / else, if / else if, etc.) to improve your family restaurant menu. This assignment is all about nested if statements.

For each dish on your menu, instead of directly asking how many the user wants and accepting any value, make the script look like this:

1.Ask the user: "Would you like [DISH NAME]?" (for example, "Would you like a bowl of chicken soup?" or "Would you like some tortilla chips?")

2.Read in a single character from the keyboard.

  • If the user typed 'Y' or 'y' then go to step 3.
  • If the user typed 'N' or 'n' then go to the next dish on the menu.
  • If the user typed anything else then say "I think you mumbled "no" so I'll just go on." (The double quotes inside the sentence must appear correctly on the screen!)

3.Ask the user "How many [DISH NAME] would you like?" and read in the answer, just like you did on the first family restaurant assignment.

  • If the user entered 0 then say "I suppose you're entitled to change your mind."
  • If the user entered a negative number say "Your generosity is appreciated but I must decline." and save 0 as the value they entered.
  • If the user entered a positive number just continue with the code you used previously to update their order.

Additional requirements:

  • Store the name of each dish in a character array.
  • Make sure the quantity of each dish is stored in a separate integer.

Phase 2

Display the menu.

Ask the customer what they would like to order.

Input their answer (text, the name of one dish), which might be more than one word. Compare their answer to the names of your dishes. (Do NOT input a number for this question!)

If you do not understand the customer's response, go to step 2.

If the customer has not already ordered this dish, ask the customer how many they would like.

If the customer has already ordered this dish, let them know how many they have already ordered and ask how many more they would like. Update the number of this dish in the order.

Display the customer's order as it currently stands.

  • list every dish they have ordered and how many of that dish they have ordered
  • list the cost of those dishes to the right (in a neat column)
  • show the subtotal cost at the bottom of the list
  • calculate and display tax amount (using 8.75% sales tax)
  • calculate and display total

Ask the user if they would like to order anything else.

If the user says yes, return to step 1.

If the user says no, ask the user to enter an amount for the tip.

If you do not understand the user's response, go to step 6.

Display the customer's receipt.

  • list every dish they have ordered and how many of that dish they have ordered
  • list the cost of those dishes to the right (in a neat column) (e.g. 2x $5 soup is $10, so show "$10.00")
  • show the subtotal cost at the bottom of the list
  • calculate and display tax amount (using 8.75% sales tax)
  • display the tip
  • calculate and display the final total
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.