Question

In: Computer Science

Joe’s Pizza Palace needs a C++ program to calculate the number of slices a pizza of...

Joe’s Pizza Palace needs a C++ program to calculate the number of slices a pizza of any size can be divided into. The program should perform the following steps:

A. Ask the user for the diameter of the pizza in inches.

B. Divide the diameter by 2 to get the radius.

C. Calculate the number of slices that may be taken from a pizza of that size if each slice has an area of 14.125 square inches.

D. Display a message telling the number of slices.

E. Modify the program you wrote so that it reports the number of pizzas you need to buy for a party if each person attending is expected to eat an average of four slices.

F. The program should ask the user for the number of people who would be at the party and for the diameter of the pizzas to be ordered.

G. It should then calculate and display the number of pizzas to purchase.

Because it is impossible to buy a part of a pizza, the number of required pizzas should display as a whole number.

(Hint: using setprecision and fixed from iomanip header file) The number of square inches in the total pizza can calculate with this formula: Area=πr2 Where variable r is the radius of the pizza and π is the Greek letter PI. In your program, make PI a named constant with the value 3.14. Display the number of slices as a whole number (i.e., with no decimals).

Solutions

Expert Solution

#include <iostream>
#include<iomanip>
using namespace std;

int main()
{
double d,r,s,area;
double totalp=0.0;
int people;
cout<<"Enter the diameter of pizza in inches: ";
cin>>d;//read diameter
r=d/2;//get radius
area=3.14*r*r;//find area
s=area/14.125;//get the number of slices where each slice has 14.125 square inches
cout<<setprecision(0)<<fixed;
cout<<"Number of slices: "<<s<<endl;
cout<<"Enter number of people attending the party: ";//read number of people
cin>>people;
people=people*4;//4 slices per person
totalp=people/s;//calculate number of pizzas
cout<<"Number of pizzas needed to be purchased: "<<totalp;
return 0;
}

Screenshots:

The screenshots are attached below for reference.

Please follow them for output.

Please upvote my answer. Thank you.


Related Solutions

Marios Pizza Palace Practice Set Part 4 The adjusted trial balance for Mario’s Pizza Palace at...
Marios Pizza Palace Practice Set Part 4 The adjusted trial balance for Mario’s Pizza Palace at 30 June is presented below: Mario's Pizza Palace Adjusted trial balance as at 30 June 20XX Account number Account Debit Credit 100 Cash 42,350 110 Cash float 450 120 Accounts receivable 679 130 Inventory - food 1,366 140 Inventory - packaging 995 150 Prepaid advertising 293 160 Prepaid insurance 1,418 170 Motor vehicles (cost) 19,290 171 Accumulated depreciation – motor vehicles 15,995 180 Store...
A pizza baker uses 100 slices of pepperoni, 50 slices of mushrooms and 150 slices of...
A pizza baker uses 100 slices of pepperoni, 50 slices of mushrooms and 150 slices of peppers for each pizza pie. After baking, he divides the pies in 10 slices. What is the probability that in one slice of pizza… There are at most 8 slices of pepperoni: 0.6672     b) 0.6472                c) 0.2202                   d) 0.3328 No mushrooms at all: 0.0067     b) 0.0498                 c) 0                              d) 0.0302 Less than 13 pepper slices: 0              b)...
You are interested in estimating the average number of pizza slices a college student eats in...
You are interested in estimating the average number of pizza slices a college student eats in one month. In a random sample of 30 college students, you find the average to be 18.924 slices with a sample variance of 120. What is the p-value for a two-sided hypothesis test where the null is that the true population mean is 14 slices per month?
Slices of pizza for a certain brand of pizza have a mass that is approximately normally...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally distributed with a mean of 67.8 grams and a standard deviation of 2.11 grams. Round answers to three decimal places. a) For samples of size 22 pizza slices, what is the standard deviation for the sampling distribution of the sample mean? Incorrect b) What is the probability of finding a random slice of pizza with a mass of less than 67.1 grams? Incorrect c)...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally distributed with a mean of 66.8 grams and a standard deviation of 1.82 grams. Round answers to three decimal places. a) For samples of size 22 pizza slices, what is the standard deviation for the sampling distribution of the sample mean? b) What is the probability of finding a random slice of pizza with a mass of less than 66.3 grams? c) What is...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally distributed with a mean of 67.3 grams and a standard deviation of 2.01 grams. a) For samples of size 22 pizza slices, what is the standard deviation for the sampling distribution of the sample mean? b) What is the probability of finding a random slice of pizza with a mass of less than 66.8 grams? c) What is the probability of finding a 22...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally distributed with a mean of 67.1 grams and a standard deviation of 2.2 grams. a) For samples of size 12 pizza slices, what is the standard deviation for the sampling distribution of the sample mean? State answer to five decimal places. b) What is the probability of finding a random slice of pizza with a mass of less than 66.5 grams? State the answer...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally...
Slices of pizza for a certain brand of pizza have a mass that is approximately normally distributed with a mean of 66.8 grams and a standard deviation of 1.94 grams. a) For samples of size 16 pizza slices, what is the standard deviation for the sampling distribution of the sample mean? b) What is the probability of finding a random slice of pizza with a mass of less than 66.3 grams? c) What is the probability of finding a 16...
  Frankie Frommagio’s Pizza Palace The competition for pizza consumers in the Bloomington Indiana market is fierce....
  Frankie Frommagio’s Pizza Palace The competition for pizza consumers in the Bloomington Indiana market is fierce. Indiana University has 38,000 undergraduate students. On average, undergraduate students eat 1.2 pizzas per person per week throughout the August 31 – May 1 academic year Frankie Frommagio’s Pizza Palace is a new competitor in the Bloomington pizza market, which includes national pizza chains such as Papa John’s, Pizza Hut and Little Caesar’s, local chains such as Avers, and Pizza X, and independent restaurants...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT