Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code in python 3.0 2. Program Description: Write a program that will display a f

ID: 3730918 • Letter: C

Question

Code in python 3.0

2. Program Description: Write a program that will display a final receipt for a customer order at Delicious Donut Shoppe. The customer can keep entering amounts for each of the following menu items they select:

Enter 1 for Donut

Enter 2 for Milk

Enter 3 for Coffee

The price for Donuts = $1.25

The price for Milk = $1.00

The price for Coffee = $1.50

Tax = $.06

The program will keep track of how many they order of each item and the total price for each item and the total order price. You will use a python while loop that will keep looping until the customer types in yes.

Results from running Python Code:

Enter 1 for Donut

Enter 2 for Milk

Enter 3 for Coffee

Enter yes to End

Enter food option now ->1

Enter the number of donuts you would like to order ->5

Enter 1 for Donut

Enter 2 for Milk

Enter 3 for Coffee

Enter yes to End

Enter food option now ->2

Enter the number of milks you would like to order ->6

Enter 1 for Donut

Enter 2 for Milk

Enter 3 for Coffee

Enter yes to End

Enter food option now ->3

Enter the number of Coffees you would like to order ->7

Enter 1 for Donut

Enter 2 for Milk

Enter 3 for Coffee

Enter yes to End

Enter food option now ->yes

*** Delicious Donut Shoppe Receipt ***

5 donuts:       $ 6.25

6 milks:          $ 6.00

7 coffees:      $ 10.50

Total:              $ 24.11

Explanation / Answer

main.py

#function to print the menu
def print_menu():
print("Enter 1 for Donut")
print("Enter 2 for Milk")
print("Enter 3 for Coffee")
print("Enter yes to End")
  
  
loop=True #local variable to check on loop continuity
number_of_donuts=0 #local variable - count on number of donuts ordered
number_of_milks=0 #local variable - count on number of milks ordered
number_of_coffees=0 #local variable - count on number of coffees ordered
total_price=0.0 #local variable - to hold the total price
tax_price=0.06 #local variable - to hold tax price

while loop:
print_menu()
choice = input(" Enter food option now-> ")
  
# if choice is donut, calculate the individual price for that number of item and add that individual price to total price
if choice=='1':
number_of_donuts=number_of_donuts+int(input("Enter the number of donuts you would like to order-> "))
donut_price = float(number_of_donuts)*1.25
total_price=total_price+donut_price
  
# if choice is milk, calculate the individual price for that number of item and add that individual price to total price
elif choice=='2':
number_of_milks=number_of_milks+int(input("Enter the number of milks you would like to order-> "))
milk_price = float(number_of_milks)*1
total_price=total_price+milk_price
  
# if choice is coffee, calculate the individual price for that number of item and add that individual price to total price
elif choice=='3':
number_of_coffees=number_of_coffees+int(input("Enter the number of Coffees you would like to order-> "))
coffee_price = float(number_of_coffees)*1.50
total_price=total_price+coffee_price
  
# if choice is yes then print the Receipt for ordered items and their prices and total price
elif choice=='yes':
loop=False
print("***Delicious Donut Shoppe Receipt***")
if int(number_of_donuts)>0:
print("{} donuts: ${:.2f}".format(number_of_donuts,donut_price))
if int(number_of_milks)>0:
print("{} milks: ${:.2f}".format(number_of_milks,milk_price))
if int(number_of_coffees)>0:
print("{} coffees: ${:.2f}".format(number_of_coffees,coffee_price))
print("Total: ${:.2f}".format(total_price+tax_price*total_price))
# it is a wrong option, continue with valid option
else:
raw_input("Wrong option selection. Enter any key to try again..")   

Output:

______

Enter 1 for Donut                                                                                     

Enter 2 for Milk                                                                                      

Enter 3 for Coffee                                                                                    

Enter yes to End                                                                                      

                                                                                                      

Enter food option now-> 1                                                                             

Enter the number of donuts you would like to order-> 5                                                

Enter 1 for Donut                                                                                     

Enter 2 for Milk                                                                                      

Enter 3 for Coffee                                                                                    

Enter yes to End                                                                                      

                                                                                                      

Enter food option now-> 2                                                                             

Enter the number of milks you would like to order-> 6                                                 

Enter 1 for Donut                                                                                     

Enter 2 for Milk                                                                                      

Enter 3 for Coffee                                                                                    

Enter yes to End                                                                                      

                                                                                                      

Enter food option now-> 3                                                                             

Enter the number of Coffees you would like to order-> 7                                               

Enter 1 for Donut                                                                                     

Enter 2 for Milk

Enter 3 for Coffee                                                                                    

Enter yes to End                                                                                      

                                                                                                      

Enter food option now-> yes                                                                           

***Delicious Donut Shoppe Receipt***                                                                  

5 donuts:      $6.25                                                                                  

6 milks:       $6.00                                                                                  

7 coffees:     $10.50                                                                                 

Total:         $24.11

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote