Need help!

for this I need to it to also show the square inches. for both of the valid entries. ok I have it for the square inches of the diameter.

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


const double PIZZA_PIE_SLICEAREA = 14.125;
const double PI = atan(1.0)*4;

int main()
{
double diameter, area, Slices_of_Pizza_per_pie;
int guests, Quantity_Of_Pizzas;
int circular, rectangular;
cout << "Welcome to Rick's Pizza PI Calculator." << endl;
cout << "\n\n";
cout << "Would you like a circular or rectangular pizza? " << endl;
cin >> circular;


cout << "\n\n";
cout << "What is the diameter of each pan pizza?" << endl;
cin >> diameter;
cout << "You entered: " << diameter << " for the diameter of each pizza." << endl;
cout<<"\n";
cout << "How many people will be at your party?" << endl;
cin >> guests;
cout<<"\n";
cout << "You entered " << guests << " guests" << endl;
area = PI * pow(diameter/2, 2.0);
cout << setprecision(2) << fixed;
Slices_of_Pizza_per_pie = area / PIZZA_PIE_SLICEAREA;
Quantity_Of_Pizzas = static_cast<int>(ceil((guests * 4) / PIZZA_PIE_SLICEAREA));
cout << setprecision(2) << fixed;
radius = diameter/2;
area1 = PI * radius * radius;

cout<<"\n\n";

cout << "You will need to order " << Quantity_Of_Pizzas
<< " pizzas for your pizza party." <<endl;

cout<<"\n\n";

cout << "Total square inches :" << area1;

cin.get();
return 0;
}

How do I do this in the same file?
1) rectangular pizza, 14 inches by 12 inches
2) when triangle is entered I need to show it's a invalid selection.
Last edited on
How do I do this in the same file?
1) rectangular pizza, 14 inches by 12 inches
2) when triangle is entered I need to show it's a invalid selection.

I think you'll need to use strings rather than integers for the type of pizza shape
As in:
1
2
3
4
5
6
7
std::string pizza_shape;
cout << "Would you like a circular or rectangular pizza? " << endl;
cin >> pizza_shape;
// then you can check with an if...
if(pizza_shape!="rectangular" && pizza_shape!="circular"){
....
}


Aceix.
Last edited on
Thanks Aceix not exactly sure how but I'll give it a shot.
I tried that and it worked great.
Topic archived. No new replies allowed.