Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Lab 5: Repetition Structures

Lab 5: Repetition Structures

Lab 5: Repetition Structures

This lab accompanies Chapter 5 of Gaddis, T. (2016). Starting out with programming logic and design (4th ed.). Boston, MA: Addison-Wesley.

Lab 5.5 – Programming Challenge 1 – Yum Yum Burger Joint

Write the Flowchart for the following programming problem and the pseudocode below.

A restaurant wants you to write a program that will calculate the cost of purchasing a meal. 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:

· Yum Yum Burger = .99

· Grease Yum Fries = .79

· 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 Pseudocode

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

The Flowchart

PASTE FLOWCHART HERE

The Python Code for Review

#the main function
def main():
endProgram = ‘no’
print
while endProgram == ‘no’:
totalBurger = 0
totalFry = 0
totalSoda = 0
endOrder = ‘no’
while endOrder == ‘no’:
print
print ‘Enter 1 for Yum Yum Burger’
print ‘Enter 2 for Grease Yum Fries’
print ‘Enter 3 for Soda Yum’
option = input(‘Enter now ->’)
if option == 1:
totalBurger = getBurger(totalBurger)
elif option == 2:
totalFry = getFry(totalFry)
elif option == 3:
totalSoda = getSoda(totalSoda)
else:
print ‘You have entered an invalid option!!!’
endOrder = raw_input(‘Do you want to end your order? (Enter yes or no): ‘)

print

total = calcTotal(totalBurger, totalFry, totalSoda)

printReceipt(total)

endProgram = raw_input(‘Do you want to end program? (Enter no to process a new order): ‘)

#this function will get burger order

def getBurger(totalBurger):

burgerCount = input(‘Enter the number of burgers you want ‘)

totalBurger = totalBurger + burgerCount * .99

return totalBurger

#this function will get fry order

def getFry(totalFry):

fryCount = input(‘Enter the number of fries you want ‘)

totalFry = totalFry + fryCount * .79

return totalFry

def getSoda(totalSoda):

sodaCount = input(‘Enter the number of sodas you want ‘)

totalSoda = totalSoda + sodaCount * 1.09

return totalSoda

def calcTotal(totalBurger, totalFry, totalSoda):

subtotal = totalBurger + totalFry + totalSoda

tax = subtotal * .06

total = subtotal + tax

return total

def printReceipt(total):

print ‘The total price is $’, total

# calls main

main()

Applied Sciences
Architecture and Design
Biology
Business & Finance
Chemistry
Computer Science
Geography
Geology
Education
Engineering
English
Environmental science
Spanish
Government
History
Human Resource Management
Information Systems
Law
Literature
Mathematics
Nursing
Physics
Political Science
Psychology
Reading
Science
Social Science
Home
Homework Answers
Blog
Archive
Tags
Reviews
Contact
twitterfacebook
Copyright © 2022 SweetStudy.comSWEETSTUDY.COM – YOUR HOMEWORK ANSWERS
chat0
Home.Literature.
Help.
Log in / Sign up
lab 5-5
profile
pying828

Lab5-5Student.docx
Home>Computer Science homework help>lab 5-5
Lab 5: Repetition Structures

This lab accompanies Chapter 5 of Gaddis, T. (2016). Starting out with programming logic and design (4th ed.). Boston, MA: Addison-Wesley.

Lab 5.5 – Programming Challenge 1 – Yum Yum Burger Joint

Write the Flowchart for the following programming problem and the pseudocode below.

A restaurant wants you to write a program that will calculate the cost of purchasing a meal. 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:

· Yum Yum Burger = .99

· Grease Yum Fries = .79

· 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 Pseudocode

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

The Flowchart

PASTE FLOWCHART HERE

The Python Code for Review

#the main function
def main():
endProgram = ‘no’
print
while endProgram == ‘no’:
totalBurger = 0
totalFry = 0
totalSoda = 0
endOrder = ‘no’
while endOrder == ‘no’:
print
print ‘Enter 1 for Yum Yum Burger’
print ‘Enter 2 for Grease Yum Fries’
print ‘Enter 3 for Soda Yum’
option = input(‘Enter now ->’)
if option == 1:
totalBurger = getBurger(totalBurger)
elif option == 2:
totalFry = getFry(totalFry)
elif option == 3:
totalSoda = getSoda(totalSoda)
else:
print ‘You have entered an invalid option!!!’
endOrder = raw_input(‘Do you want to end your order? (Enter yes or no): ‘)

print

total = calcTotal(totalBurger, totalFry, totalSoda)

printReceipt(total)

endProgram = raw_input(‘Do you want to end program? (Enter no to process a new order): ‘)

#this function will get burger order

def getBurger(totalBurger):

burgerCount = input(‘Enter the number of burgers you want ‘)

totalBurger = totalBurger + burgerCount * .99

return totalBurger

#this function will get fry order

def getFry(totalFry):

fryCount = input(‘Enter the number of fries you want ‘)

totalFry = totalFry + fryCount * .79

return totalFry

def getSoda(totalSoda):

sodaCount = input(‘Enter the number of sodas you want ‘)

totalSoda = totalSoda + sodaCount * 1.09

return totalSoda

def calcTotal(totalBurger, totalFry, totalSoda):

subtotal = totalBurger + totalFry + totalSoda

tax = subtotal * .06

total = subtotal + tax

return total

def printReceipt(total):

print ‘The total price is $’, total

# calls main

main()

Applied Sciences
Architecture and Design
Biology
Business & Finance
Chemistry
Computer Science
Geography
Geology
Education
Engineering
English
Environmental science
Spanish
Government
History
Human Resource Management
Information Systems
Law
Literature
Mathematics
Nursing
Physics
Political Science
Psychology
Reading
Science
Social Science
Home
Homework Answers
Blog
Archive
Tags
Reviews
Contact
twitterfacebook
Copyright © 2022 SweetStudy.com

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Blackboard Experts only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Blackboard Experts are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Blackboard Experts is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Blackboard Experts, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.