Midterm Exam
Part01: Programming part (25% of midterm score)
You are a
anging a pizza party for all of your friends. You want to
figure out how much pizza you can order without exceeding your budget.
Write a program that accepts:
• the number of people attending your party,
• the budget for your party,
• the price per slice of pizza,
• the price per pie of pizza.
• how many slices each person wants
Your program should determine how many individual slices and pies to
order without exceeding your budget. If you exceed your budget, the
program should warn the user they can't place their order.
Note that for the purpose of this program a pizza pie contains 8 slices.
And note that the restaurant you are ordering from will not sell you
more than 7 individual slices at a time (if you need to purchase 8 slices
you will have to buy a whole pie).
We assume the user will enter valid input data.
Hint:
• A loop is needed to enter the number of slices for each person.
• Use the integer division and the remainder to count the number of
pies and slices.
• Example:
o 18 / 4 = 4
o 18 % 4 = 2
Example input/output
Enter budget for your party: 100
Cost per slice of pizza: 2.50
Cost per whole pizza pie (8 slices): 12.50
How many people will be attending your party? 10
Enter number of slices for person #1: 2
Enter number of slices for person #2: 3
Enter number of slices for person #3: 4
Enter number of slices for person #4: 2
Enter number of slices for person #5: 3
Enter number of slices for person #6: 4
Enter number of slices for person #7: 2
Enter number of slices for person #8: 1
Enter number of slices for person #9: 5
Enter number of slices for person #10: 4
You should purchase 3 pies and 6 slices
Your total cost will be: 52.50
You will still have 47.50 left after your order
Example input/output
Enter budget for your party: 10
Cost per slice of pizza: 2.50
Cost per whole pizza pie (8 slices): 12.50
How many people will be attending your party? 4
Enter number of slices for person #1: 1
Enter number of slices for person #2: 1
Enter number of slices for person #3: 1
Enter number of slices for person #4: 1
You should purchase 0 pies and 4 slices
Your total cost will be: 10.00
You will have no money left after your order.
Example input/output
Enter budget for your party: 10
Cost per slice of pizza: 2.50
Cost per whole pizza pie (8 slices): 12.50
How many people will be attending your party? 4
Enter number of slices for person #1: 2
Enter number of slices for person #2: 2
Enter number of slices for person #3: 2
Enter number of slices for person #4: 2
Your order cannot be completed.
You would need to purchase 1 pies and 0 slices
This would put you over budget by 2.50
Notes:
• Your output should look like the given sample run (5pts)
• Name your program as LastNameFirstName_Midterm_part1.cpp (2pts)
• Other file types not accepted (.cpp only)
• If the program does not run, a grade of zero will be received.
Take Test: Quiz #4 (Functions) – 2021 Fall Term (1) ...
Skip To Content
Open Quick Links
Quick Links
Page Landmarks
Content Outline
Keyboard Shortcuts
Logout
Make this website talk
Global Menu
Mohamad BekhitActivity Updates1 Home
Help
XXXXXXXXXXTop Frame Tabs
XXXXXXXXXXHome
XXXXXXXXXXTab 1 of 4Â (active tab)
XXXXXXXXXXTech Resources/Help
XXXXXXXXXXTab 2 of 4
XXXXXXXXXXLaGuardia Li
ary
XXXXXXXXXXTab 3 of 4
XXXXXXXXXXLaGuardia Website
XXXXXXXXXXTab 4 of 4
Cu
ent Location
XXXXXXXXXX2021 Fall Term (1) Introduction to Computer Science MAC XXXXXXXXXX[24841] (LaGuardia CC)
XXXXXXXXXXContent
XXXXXXXXXXTake Test: Quiz #4 (Functions)
Menu Management Options
Course Menu:
2021 Fall Term (1) Introduction to Computer Science MAC XXXXXXXXXX[24841] (LaGuardia CC)
Home Page
Content
Discussions
Groups
Collaborate
Tools
Help
Take Test: Quiz #4 (Functions)
Content
Assistive Technology Tips [opens in new window]
Test Information
Instructions
Description
Instructions
Multiple Attempts
This test allows 5 attempts. This is attempt number 1.
Force Completion
This test can be saved and resumed later.
Question Completion Status:
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX