Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COMPUTER SCIENCE ASSIGNMENT QUESTION Please base the code off of this: (indentation is off) #welcomes user and asks for name print(Welcome to Dino's International Doughnut

COMPUTER SCIENCE ASSIGNMENT QUESTION image text in transcribed

Please base the code off of this:

image text in transcribed

(indentation is off)

#welcomes user and asks for name print("Welcome to Dino's International Doughnut Shoppe!") name = input("Please enter your name to begin: ")

#asks user for a choice chocolate = strawberry = vanilla = honey = 0 done = False while not done: print("Please enter a valid choice from 1-4.") print("Please select a doughnut from the following menu: ") print("1. Chocolate-dipped Maple Puff ($3.50 each)") print("2. Strawberry Twizzler ($2.25 each)") print("3. Vanilla Chai Strudel ($4.05 each)") print("4. Honey-drizzled Lemon Dutchie ($1.99)") print("5. No more doughnuts.") choice = int(input(">"))

#if-elif statements for choices if choice == 1: chocolate = int(input("How many chocolate-dipped Maple Puff(s) would you like to purchase? ")) elif choice == 2: strawberry = int(input("How many Strawberry Twizzler(s) would you like to purchase? ")) elif choice == 3: vanilla = int(input("How many Vanilla Chai Strudel(s) would you like to purchase? ")) elif choice == 4: honey = int(input("How many Honey-drizzled Lemon Dutchie(s) would you like to purchase? ")) elif choice == 5: done = True print(f"{name}, Here is your receipt: ") #receipt

if chocolate >= 1: print("==========================================") print(f"{chocolate} Chocolate Dipped Maple Puffs") if strawberry >= 1: print(f"{strawberry} Strawberry Twizzlers") if vanilla >= 1: print(f"{vanilla} Vanilla Chai Strudels") if honey >= 1: print(f"{honey} Honey-drizzled Lemon Dutchies") print("==========================================") print(f"Total Cost for Today: ${chocolate*3.50 + strawberry*2.25 + vanilla*4.05 + honey*1.99:.2f}") print("Thank you for shopping at Dino's International Doughnut Shoppe! Please come again!")

For this third part, you will be using files to record all sales that occur at Dino's shop. Again, copy your solution from the previous part into a new file called a3q3.py. Do not overwrite your previous solution, as the TAs will want to see all of them Modify your code from the previous part so that once the customer has selected "No more doughnuts", the information for their order is added to a file called "sales.txt". The information you must record includes the customer's name and the number of each donut type. You are free to structure your file in any way you wish, but a suggested structure is given below (note: these are descriptions of what each line of the file would represent - the actual values saved in the file should be the variable values from the program) Customer Name (purchase #1) # of Chocolate-dipped Maple Puff (purchase #1) # of Strawberry Twizzler (purchase #1) # of Vanilla Chai Strudel (purchase #1) # of Honey-drizzled Lemon Dutchies (purchase #1) 4 COMP 1001B-W19-A3 Due Thursday, March 7h at 11:55 PM Customer Name (purchase #2) # of Chocolate-dipped Maple Puff (purchase #2) # of Strawberry Twizzler (purchase #2) # of Vanilla Chai Strudel (purchase #2) # of Honey-drizzled Lemon Dutchies (purchase #2) etc Add a final option to the donut selection menu that allows the user to select "Display sales statistics". When this option is selected, the program should read the sales.txt file and print out: the total number of sales that have been made, the total dollar amount of all purchases, the average dollar amount of all purchases, and the name of the customer with the largest single purchase. It may be easier to implement/test the sales statistics functionality in a separate program first and then copy the code into your final Dino's program 3 #welcomes user and asks for name 4 print("Welcome to Dino's International Doughnut Shoppe!") name input("Please enter your name to begin:") 7 #asks user for a choice chocolate strawberryvanilla-honey0 done False 10 while not done: print("Please enter a valid choice from 1-4.") print("Please select a doughnut from the following menu: ") print("1. Chocolate-dipped Maple Puff ($3.50 each)") print("2. Strawberry Twizzler ($2.25 each)") print("3. Vanilla Chai Strudel ($4.05 each)") print("4. Honey-drizzled Lemon Dutchie ($1.99)") print ("5. No more doughnuts.") choiceint (input(">")) 12 15 18 20 #if-elif statements for choices 21 if choice 1: chocolate int(input ("How many chocolate-dipped Maple Puff(s) would you like to purchase?")) strawberry int(input("How many Strawberry Twizzler(s) would you like to purchase? ")) vanilla-int (input("How many Vanilla Chai Strudel(s) would you like to purchase? ")) honey int(input( "How many Honey-drizzled Lemon Dutchie(s) would you like to purchase? ")) done True 23 24 elif choice 2: elif choice3: elif choice4: 26 28 29 30 elif choice 5: print (f"(name. Here is your receipt. ") #receipt 32 if chocolate 1: print(" print (f"chocolate Chocolate Dipped Maple Puffs") print(f"Istrawberry Strawberry Twizzlers") print (f"vanilla Vanilla Chai Strudels") print(f"ThoneyHoney-drizzled Lemon Dutchies") 35 36 38 39 40 if strawberry- 1: if vanilla 1: if honey >= 1: 42 43 print(" print (f"Total Cost for Today: ${chocolate#3.50 + strawberry#2.25 + vanilla*4.05 + honey#1.99 :"2t)") print("Thank you for shopping at Dino's International Doughnut Shoppe! Please come again!") For this third part, you will be using files to record all sales that occur at Dino's shop. Again, copy your solution from the previous part into a new file called a3q3.py. Do not overwrite your previous solution, as the TAs will want to see all of them Modify your code from the previous part so that once the customer has selected "No more doughnuts", the information for their order is added to a file called "sales.txt". The information you must record includes the customer's name and the number of each donut type. You are free to structure your file in any way you wish, but a suggested structure is given below (note: these are descriptions of what each line of the file would represent - the actual values saved in the file should be the variable values from the program) Customer Name (purchase #1) # of Chocolate-dipped Maple Puff (purchase #1) # of Strawberry Twizzler (purchase #1) # of Vanilla Chai Strudel (purchase #1) # of Honey-drizzled Lemon Dutchies (purchase #1) 4 COMP 1001B-W19-A3 Due Thursday, March 7h at 11:55 PM Customer Name (purchase #2) # of Chocolate-dipped Maple Puff (purchase #2) # of Strawberry Twizzler (purchase #2) # of Vanilla Chai Strudel (purchase #2) # of Honey-drizzled Lemon Dutchies (purchase #2) etc Add a final option to the donut selection menu that allows the user to select "Display sales statistics". When this option is selected, the program should read the sales.txt file and print out: the total number of sales that have been made, the total dollar amount of all purchases, the average dollar amount of all purchases, and the name of the customer with the largest single purchase. It may be easier to implement/test the sales statistics functionality in a separate program first and then copy the code into your final Dino's program 3 #welcomes user and asks for name 4 print("Welcome to Dino's International Doughnut Shoppe!") name input("Please enter your name to begin:") 7 #asks user for a choice chocolate strawberryvanilla-honey0 done False 10 while not done: print("Please enter a valid choice from 1-4.") print("Please select a doughnut from the following menu: ") print("1. Chocolate-dipped Maple Puff ($3.50 each)") print("2. Strawberry Twizzler ($2.25 each)") print("3. Vanilla Chai Strudel ($4.05 each)") print("4. Honey-drizzled Lemon Dutchie ($1.99)") print ("5. No more doughnuts.") choiceint (input(">")) 12 15 18 20 #if-elif statements for choices 21 if choice 1: chocolate int(input ("How many chocolate-dipped Maple Puff(s) would you like to purchase?")) strawberry int(input("How many Strawberry Twizzler(s) would you like to purchase? ")) vanilla-int (input("How many Vanilla Chai Strudel(s) would you like to purchase? ")) honey int(input( "How many Honey-drizzled Lemon Dutchie(s) would you like to purchase? ")) done True 23 24 elif choice 2: elif choice3: elif choice4: 26 28 29 30 elif choice 5: print (f"(name. Here is your receipt. ") #receipt 32 if chocolate 1: print(" print (f"chocolate Chocolate Dipped Maple Puffs") print(f"Istrawberry Strawberry Twizzlers") print (f"vanilla Vanilla Chai Strudels") print(f"ThoneyHoney-drizzled Lemon Dutchies") 35 36 38 39 40 if strawberry- 1: if vanilla 1: if honey >= 1: 42 43 print(" print (f"Total Cost for Today: ${chocolate#3.50 + strawberry#2.25 + vanilla*4.05 + honey#1.99 :"2t)") print("Thank you for shopping at Dino's International Doughnut Shoppe! Please come again!")

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

What are the role of supervisors ?

Answered: 1 week ago