Taking a Restaurant Order: Sentinel Style. Using the restaurant menu you selected in assigment below , you will create a program that will take an order from a customer and calculate the total. Your program shall, Display the menu with the prices. Take an order using the Sentinel approach in section 5.2.5 (atatched)  The user will input numbers between 1 and 10, according to the menu you created below. Use zero as sentinel value (see Listing 5.5, p. 141) Inform the user about invalid input values (greater than 10 or less than 0) Add the prices of the dishes ordered  After taking the order, the program displays the subtotal, the sales tax (8.75%), the grand total, and a suggested 15% tip.   You can use the program you created below and modify to incorporate the new requirements. Notice that you will still need the multi-way conditional to add the right price value to the running total of the order.     import sys #Enter number for each dish and price for users DishNumber= float(input("Enter numbers between 1 and 10:")) if DishNumber == 1: print("Cajun Calamari price is $9.00") elif DishNumber== 2: print("Shrimp Cocktail price is $9.00") elif DishNumber== 3: print:("Spicy Garlic Mussels price is $9.00") elif DishNumber== 4: print("Crispy Ahi price is $10.50") elif DishNumber== 5: print("Spinach Artichoke Dip price is $8.00") elif DishNumber== 6: print("Steamed Clams price is $10.00") elif DishNumber== 7: print("Chips and Dip price is $6.50") elif DishNumber== 8: print:("Beer Battered Ribs price is $6.00") elif DishNumber== 9: print("St.Louis Ribs price is $8.00") elif DishNumber== 10: print("Mozzarella Sticks price is $7.00") else: print("Error: Select number between 1 and 10")

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Taking a Restaurant Order: Sentinel Style. Using the restaurant menu you selected in assigment below , you will create a program that will take an order from a customer and calculate the total.

Your program shall,

  • Display the menu with the prices.
  • Take an order using the Sentinel approach in section 5.2.5 (atatched)  The user will input numbers between 1 and 10, according to the menu you created below.
  • Use zero as sentinel value (see Listing 5.5, p. 141)
  • Inform the user about invalid input values (greater than 10 or less than 0)
  • Add the prices of the dishes ordered 
  • After taking the order, the program displays the subtotal, the sales tax (8.75%), the grand total, and a suggested 15% tip.

 

You can use the program you created below and modify to incorporate the new requirements. Notice that you will still need the multi-way conditional to add the right price value to the running total of the order.

 

 


import sys

#Enter number for each dish and price for users

DishNumber= float(input("Enter numbers between 1 and 10:"))

if DishNumber == 1:
print("Cajun Calamari price is $9.00")

elif DishNumber== 2:
print("Shrimp Cocktail price is $9.00")

elif DishNumber== 3:
print:("Spicy Garlic Mussels price is $9.00")

elif DishNumber== 4:
print("Crispy Ahi price is $10.50")

elif DishNumber== 5:
print("Spinach Artichoke Dip price is $8.00")

elif DishNumber== 6:
print("Steamed Clams price is $10.00")

elif DishNumber== 7:
print("Chips and Dip price is $6.50")

elif DishNumber== 8:
print:("Beer Battered Ribs price is $6.00")

elif DishNumber== 9:
print("St.Louis Ribs price is $8.00")

elif DishNumber== 10:
print("Mozzarella Sticks price is $7.00")

else:
print("Error: Select number between 1 and 10")

### 5.2.5 Controlling a Loop with a Sentinel Value

Another common technique for controlling a loop is to designate a special input value, known as a **sentinel value**, which signifies the end of the input. A loop that uses a sentinel value in this way is called a **sentinel-controlled loop**.

The program in Listing 5.5 reads and calculates the sum of an unspecified number of integers. The input **0** signifies the end of the input. You don't need to use a new variable for each input value. Instead, use a variable named `data` (line 1) to store the input value and use a variable named `sum` (line 5) to store the total. Whenever a value is read, assign it to `data` (line 9) and add it to `sum` (line 7) if it is not zero.

**Listing 5.5 SentinelValue.py**

```python
1  data = eval(input("Enter an integer (the input ends " + 
2                   "if it is 0): "))        # input data
3
4  # Keep reading data until the input is 0
5  sum = 0
6  while data != 0:                         # loop
7      sum += data
8
9      data = eval(input("Enter an integer (the input ends " + 
10                      "if it is 0): "))    # input data
11
12 print("The sum is", sum)                  # output result
```

This program snippet shows how to implement a simple sentinel-controlled loop. Here’s a step-by-step explanation:

1. **Prompt User for Initial Input:**
    - `data = eval(input("Enter an integer (the input ends if it is 0): "))`
    - The program prompts the user to enter an integer. If the user enters 0, no further inputs are taken.

2. **Initialize the Summation Variable:**
    - `sum = 0`
    - A variable `sum` is initialized to accumulate the total of the entered numbers.

3. **Loop until User Enters Sentinel Value:**
    - `while data != 0:` 
    - This loop continues to execute as long as the user does not enter 0.

4. **Update Sum and Prompt for Next Input:**
    - `sum += data`
    - The entered data
Transcribed Image Text:### 5.2.5 Controlling a Loop with a Sentinel Value Another common technique for controlling a loop is to designate a special input value, known as a **sentinel value**, which signifies the end of the input. A loop that uses a sentinel value in this way is called a **sentinel-controlled loop**. The program in Listing 5.5 reads and calculates the sum of an unspecified number of integers. The input **0** signifies the end of the input. You don't need to use a new variable for each input value. Instead, use a variable named `data` (line 1) to store the input value and use a variable named `sum` (line 5) to store the total. Whenever a value is read, assign it to `data` (line 9) and add it to `sum` (line 7) if it is not zero. **Listing 5.5 SentinelValue.py** ```python 1 data = eval(input("Enter an integer (the input ends " + 2 "if it is 0): ")) # input data 3 4 # Keep reading data until the input is 0 5 sum = 0 6 while data != 0: # loop 7 sum += data 8 9 data = eval(input("Enter an integer (the input ends " + 10 "if it is 0): ")) # input data 11 12 print("The sum is", sum) # output result ``` This program snippet shows how to implement a simple sentinel-controlled loop. Here’s a step-by-step explanation: 1. **Prompt User for Initial Input:** - `data = eval(input("Enter an integer (the input ends if it is 0): "))` - The program prompts the user to enter an integer. If the user enters 0, no further inputs are taken. 2. **Initialize the Summation Variable:** - `sum = 0` - A variable `sum` is initialized to accumulate the total of the entered numbers. 3. **Loop until User Enters Sentinel Value:** - `while data != 0:` - This loop continues to execute as long as the user does not enter 0. 4. **Update Sum and Prompt for Next Input:** - `sum += data` - The entered data
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY