Question

A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices...

A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices a pizza of any aize can be divided into, and hoe many pizzas should be ordered for a party. The program will assume each person at the party will eat 3 slices of pizza each.

The program should prompt the user for the diameter of the pizzas they wish to order. it will also ask the user for the number of people who will be at the party. The program will then calculate and display the number of slices per pizza and the number of pieces needed for the party (must be full pizzas).

- A slice must have an area of 14.125 inches
- Number of slices per pizza is the area of the pizza divided by the area of a slice
- Area of a piece is calculated with Area = Pl*r^2
•Pl = 3.14159
• r is the radius of the pizza
- The number of slices should be a fixed point and rounded to one decimal place
- Pl must be a named constant

include psuedocode


C++ language
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    const double areaOfSlice = 14.125;//In inches^2
    const double PI = 3.14159;
    double diameter, radius, areaOfPizza;
    int numberOfPeople;

    cout << "Enter diameter of pizzas: ";
    cin >> diameter;
    cout << "Enter number of people who will be at the party: ";
    cin >> numberOfPeople;

    radius = diameter/2;//Radius of pizza

    areaOfPizza = PI*radius*radius;//Area of a piece

    int numberOfSlicesPerPizza = areaOfPizza/areaOfSlice;//Calculate number of slices in a single pizza

    int numberOfPizzas = ceil(numberOfPeople * 3.0 / numberOfSlicesPerPizza);//Calculate number of pizzas needed

    cout << "Number of slices per pizza: " << numberOfSlicesPerPizza << endl;
    cout << "Number of pizzas needed for the party: " << numberOfPizzas << endl;
    return 0;
}

SAMPLE OUTPUT:

Pseudocode:

START
    input diameterOfPizza
    input numberOfPeople
    radius = diameterOfPizza
    areaOfPizza = 3.14159*radius*radius
    numberOfSlicesPerPizza = areaOfPizza/14.125
    numberOfPizzas = ceil(numberOfPeople*3/numberOfSlicesPerPizza)
    output numberOfSlicesPerPizza
    output numberOfPizzas
END
Add a comment
Know the answer?
Add Answer to:
A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Murphy Pizza Palace needs an application to calculate the number of slices of a pizzaof any...

    Murphy Pizza Palace needs an application to calculate the number of slices of a pizzaof any size can be divided into. The application should do the following: Allow the user to enter the diameter of the pizza, in inches. Calculate the number of slices that can be cut from a pizza that size. Display a message that indicates the number of slices. To calculate the number of slices that can be cut from the pizza, you must know the following...

  • (The file should have your program and the console input/output of your program) 3.18: Pizza Pi...

    (The file should have your program and the console input/output of your program) 3.18: Pizza Pi Joe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. The program should perform the following steps: Ask the user for the diameter of the pizza in inches. Calculate the number of slices that may be taken from a pizza of that size. Display a message telling the number of slices. To calculate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT