C++ Part 1- Count your Many Pizzas • Prompt the user for how many guests to order for. • Determine and report the number of large, medium, and small pizzas you need to order. • For every 7 guests, order one large pizza. • For every 3 guests left over, order one medium pizza. • For every 1 guest left over, order one small pizza. Part 2 - Serving Size • Compute and report the total area of pizza (in square inches) you need to order. Do not round these values. • Compute and report the total area of pizza (in square inches) each guest can eat. Do not round these values. Part 3 - Supplementing the Budget • Prompt the user for the percent of the total price to be paid as a tip. The tip percentage will be input as a whole integer from 0 to 100. • Compute and report the total cost (including tip) of all the pizzas, rounding to the nearest dollar. Note: Changing the value type into an int alone will not round to the nearest dollar. See the end of the "Notes" section below.
This is the code I have so far:
#include <iostream>
#include<cmath>
//for round function
using namespace std;
void calculatePizza(int noOfGuests);
void calculatePizza(int noOfGuests){
//Declare the costs of each sized pizza
double largeCost=14.68,mediumCost=11.48,smallCost=7.28,guests=noOfGuests;
//number of large count pizzas
int largeCount=noOfGuests/7;
noOfGuests%=7;
//number of medium count pizzas
int mediumCount=noOfGuests/3;
noOfGuests%=3;
//number of smallcount pizas
int smallCount=noOfGuests;
//Find the cost of pizzas
double cost=largeCount*largeCost+mediumCount*mediumCost+smallCost*smallCount;
//Assuming the size of large size pizza is 30 , medium size pizza is 20 small size pizza is 10 sqinches
double size=largeCount*20+mediumCount*16+smallCount*12;
cout<<largeCount<<" large pizzas, "<<mediumCount<<" medium pizzas, "<<"and "<<smallCount<<" small pizzas will be needed."<<endl;
cout<<endl;
cout<<"A total of "<<size<< " square inches of pizza will be ordered ("<<size/guests<<" per guest)."<<endl;
cout<<endl;
int tipPercent;
cout<<"Please enter the tip as a percentage (i.e. 10 means 10%): "<<endl;
cin>>tipPercent;
double tip= round(cost*(tipPercent/100));
cout<<"The total cost of the event will be: $"<<cost+tip<<endl;
}
int main()
{
cout<<"Please enter how many guests to order for: "<<endl;
int noOfGuests;
cin>>noOfGuests;
calculatePizza(noOfGuests);
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images