![HappyBeatrice1401](/avatars/5576.jpg)
HappyBeatrice1401
09.11.2020 •
Computers and Technology
And Python code for the following programming problem and the pseudo code below
Write a modular program that will calculate the cost of purchasing a meal. The Python program can use global or local variables and RAPTOR use global variables. This program will include decisions and loops. Details of the program are as follows:
• Your menu items only include the following food with accompanied price:
o Yum Yum Burger = .99
o Grease Yum Fries = .79
o Soda Yum = 1.09
• Allow the user of the program to purchase any quantity of these items on one order.
• Allow the user of the program to purchase one or more types of these items on one order.
• After the order is placed, calculate total and add a 6% sales tax.
• Print to the screen a receipt showing the total purchase price.
Your sample output might look as follows:
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->1
Enter the number of burgers you want 3
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->3
Enter the number of sodas you want 2
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->1
Enter the number of burgers you want 1
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->2
Enter the number of fries you want 2
Do you want to end your order? (Enter yes or no): yes
The total price is $ 8.1832
Do you want to end program? (Enter no to process a new order): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->2
Enter the number of fries you want 2
Do you want to end your order? (Enter yes or no): no
Enter 1 for Yum Yum Burger
Enter 2 for Grease Yum Fries
Enter 3 for Soda Yum
Enter now ->3
Enter the number of sodas you want 2
Do you want to end your order? (Enter yes or no): yes
The total price is $ 3.9856
Do you want to end program? (Enter no to process a new order): yes
The Pseudo code is:
Module main()
Call declareVariables(endProgram, endOrder, totalBurger, totalFry, totalSoda, total, tax, subtotal, option, burgerCount, fryCount, sodaCount)
//Loop to run program again
While endProgram == "no"
Call resetVariables(totalBurger, totalFry, totalSoda, total, tax, subtotal)
//Loop to take in order
While endOrder == "no"
Display "Enter 1 for Yum Yum Burger"
Display "Enter 2 for Grease Yum Fries"
Display "Enter 3 for Soda Yum"
Input option
If option == 1 Then
Call getBurger(totalBurger, burgerCount)
Else If option == 2 Then
Call getFry(totalFry, fryCount)
Else If option == 3 Then
Call getSoda(totalSoda, sodaCount)
End If
Display "Do you want to end your order? (Enter no to add more items: )"
Input endOrder
End While
Call calcTotal(burgerTotal, fryTotal, sodaTotal, total, subtotal, tax)
Call printReceipt(total)
Display "Do you want to end the program? (Enter no to process a new order)"
Input endProgram
End While
End Module
Module declareVariables(String Ref endProgram, String Ref endOrder, Real Ref totalBurger, Real Ref totalFry, Real Ref totalSoda, Real Ref total, Real Ref tax, Real Ref subtotal, Real Ref option, Real Ref burgerCount, Real Ref fryCount, Real Ref sodaCount)
Declare String endProgram = "no"
Declare String endOrder = "no"
Declare Real totalBurger = 0
Declare Real totalFry = 0
Declare Real totalSoda = 0
Declare Real total = 0
Declare Real tax = 0
Declare Real subtotal = 0
Declare Integer option = 0
Declare Integer burgerCount = 0
Declare Integer fryCount = 0
Declare Integer sodaCount = 0
End Module
Module resetVariables (Real Ref totalBurger, Real Ref totalFry, Real Ref totalSoda, Real Ref total, Real Ref tax, Real Ref subtotal)
//reset variables
totalBurger = 0
totalFry = 0
totalSoda = 0
total = 0
tax = 0
subtotal = 0
End Module
Module getBurger(Real Ref totalBurger, Integer burgerCount)
Display "Enter the number of burgers you want"
Input burgerCount
Set totalBurger = totalBurger + burgerCount * .99
End Module
Module getFry(Real Ref totalFry, Integer fryCount)
Display "Enter the number of fries you want"
Input fryCount
Set totalFry = totalFry + fryCount * .79
End Module
Module getSoda(Real Ref totalSoda, Integer sodaCount)
Display "Enter the number of sodas you want"
Input sodaCount
Set totalSoda = totalSoda + sodaCount * 1.09
End Module
Module calcTotal(Real totalBurger, Real totalFry, Real totalSoda, Real Ref total, Real subtotal, Real tax)
Set subtotal = totalBurger + totalFry + totalSoda
Set tax = subtotal * .06
Set total = subtotal + tax
End Module
Module printReceipt(Real total)
Display "Your total is $", total
End Module
Solved
Show answers
More tips
- F Food and Cooking Deflope: What is it and how does it work?...
- B Business and Finance How to Create a Business Plan? Your Ultimate Guide...
- F Food and Cooking Unusually Delicious Shashlik - Follow the Etiquette of Proper Preparation!...
- C Computers and Internet Make Easy Accessible Screenshots on iPad in Just a Few Minutes...
- T Travel and tourism Lost in the Catacombs: What to Do?...
- F Family and Home Protect Your Home or Apartment from Pesky Ants...
- H Health and Medicine How to Treat Styes: Causes, Symptoms, and Home Remedies...
- L Legal consultation What Documents Are Required for a Russian Passport?...
- F Family and Home How to Properly Use a Water Level?...
- H Horoscopes, Magic, Divination How to Cast a Love Spell on a Guy? Guide for Guys...
Answers on questions: Computers and Technology
- C Computers and Technology Which set, if any, in the data cache is accessed due to executing the two instructions: lui $t2,0x17 lw $t3,0x644($t2)...
- C Computers and Technology You can perform mathematical operation on String ? yes or No...
- E English What is the best definition of the term characterization ?...
- E English 99 points! match the poetic term with its definition. 1. alliteration a.how a poem is grouped into words, lines, and stanzas 2. metaphor b.the pattern of long and short syllables...
- E English During world war 2 the us government sent people of japanese ancestry to internment camps base on...
- H History How long did the israelites live in canaan?...
- B Biology What is the shape of a planet’s orbit ?...
- P Physics Abase is a compound that turns litmus blue and is often found in soaps and detergents.t or f for 98 points and brainliest i need the answer asap...
- H History Similarities between sam houston and mirabeau lamar...
- B Biology Which is the constant variable in this experiment? a: mass of marble b: kinetic energy of marble c: potential energy of marble d: height of marble from ground...
Ответ:
endProgram = "no"
endOrder = "no"
totalBurger = 0
totalFry = 0
totalSoda = 0
total = 0
tax = 0
subtotal = 0
option = 0
burgerCount = 0
fryCount = 0
sodaCount = 0
def resetVariables():
#reset variables
totalBurger = 0
totalFry = 0
totalSoda = 0
total = 0
tax = 0
subtotal = 0
def getBurger():
global burgerCount
burgerCount += int(input("Enter the number of burgers you want: "))
totalBurger =burgerCount * .99
return totalBurger
def getFry():
global fryCount
fryCount += int(input("Enter the number of fries you want: "))
global totalFry
totalFry +=fryCount * .79
return totalFry
def getSoda():
global sodaCount
sodaCount += int(input("Enter the number of sodas you want: "))
global totalSoda
totalSoda +=sodaCount * 1.09
return totalSoda
def calcTotal():
global subtotal
subtotal += totalBurger + totalFry + totalSoda
global tax
tax += subtotal * .06
global total
total += subtotal + tax
return total
def printReceipt(total):
print("Your total is $",round(total, 2))
#Loop to run program again
while endProgram == "no":
resetVariables()
#Loop to take in order
while endOrder == "no":
print("Enter 1 for Yum Yum Burge\nEnter 2 for Grease Yum Fries\nEnter 3 for Soda Yum: \n")
option = int(input("Enter option: "))
if option == 1:
bugertotal = getBurger()
elif option == 2:
frytotal = getFry()
elif option == 3:
sodatotal = getSoda()
endOrder = input("Do you want to end your order? (Enter no to add more items): ")
mytotal = calcTotal()
printReceipt(mytotal)
endProgram = input("Do you want to end the program? (Enter no to process a new order): ")
Explanation:
The python source code displays the menu of a restaurant and the prices of each meal. The module takes multiple orders, calculates and displays the total bill of the order with tax included.
Ответ: