1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const double PI = 3.14;
void Size(double&, double&, double&);
void Price(double&, double&, double&);
double Radius(double&, double&, double&, double&, double&, double&);
double Area(double&, double&, double&);
double Perinch(double&, double&, double&, double&, double&, double&);
void Bestbuy(double&, double&, double&, double&, double&, double&, double&, double&, double&);
int main()
{
cout << "Hello, please enter the size and the price of the pizza you want." << endl;
cout << " Small Pizza has to be between 5 to 7 inches " << endl;
cout << " Medium pizza has to be between 8 to 10 inches " << endl;
cout << " Large pizza has to be between 11 to 13 inches " << endl;
cout << "\n";
double smallsize,
mediumsize,
largesize,
smallprice,
mediumprice,
largeprice,
smallarea,
mediumarea,
largearea,
smallinch,
mediuminch,
largeinch,
sradius,
mradius,
lradius;
Size(smallsize, mediumsize, largesize);
Price(smallprice, mediumprice, largeprice);
Radius(sradius, mradius, lradius, smallarea, mediumarea, largearea);
Area(smallarea, mediumarea, largearea);
Perinch(smallinch, mediuminch, largeinch, smallprice, mediumprice, largeprice);
Bestbuy(smallarea, mediumarea, largearea, smallprice, mediumprice, largeprice, smallinch, mediuminch, largeinch);
system("pause");
return 0;
}
void Size(double&smallsize, double& mediumsize, double& largesize) {
do {
cout << "Small pizza Diameter (in inches) = " << endl;
cin >> smallsize;
} while (smallsize < 5 || smallsize > 7);
do {
cout << "Medium pizza Diameter (in inches) = " << endl;
cin >> mediumsize;
} while (mediumsize < 8 || mediumsize > 10);
do {
cout << "Large pizza Diameter (in inches) = " << endl;
cin >> largesize;
} while (largesize < 11 || largesize > 13);
}
void Price(double&smallprice, double&mediumprice, double&largeprice)
{
cout << "Enter the price of the small pizza = $" << endl;
cin >> smallprice;
cout << "Enter the price of the medium pizza = $" << endl;
cin >> mediumprice;
cout << "Enter the price of the large pizza = $" << endl;
cin >> largeprice;
}
double Radius(double&sradius, double&mradius, double&lradius, double&smallarea, double&mediumarea, double&largearea)
{
double smallsize = 0.00,
mediumsize = 0.00,
largesize = 0.00;
sradius = (smallsize / 2);
mradius = (mediumsize / 2);
lradius = (largesize / 2);
return (sradius, mradius, lradius);
}
double Area(double&smallarea, double&mediumarea, double&largearea)
{
double sradius = 0.00,
mradius = 0.00,
lradius = 0.00;
smallarea = (PI * sradius) * 2;
mediumarea = (PI * mradius) * 2;
largearea = (PI * lradius) * 2;
return (smallarea, mediumarea, largearea);
}
double Perinch(double&smallinch, double&mediuminch, double&largeinch, double&smallprice, double&mediumprice, double&largeprice)
{
double smallarea = 0.00,
mediumarea = 0.00,
largearea = 0.00;
smallinch = (smallprice / smallarea);
mediuminch = (mediumprice / mediumarea);
largeinch = (largeprice / largearea);
return (smallinch, mediuminch, largeinch);
}
void Bestbuy(double&smallarea, double&mediumarea, double&largearea, double&smallprice, double&mediumprice, double&largeprice, double&smallinch, double&mediuminch, double&largeinch)
{
cout << "\n";
cout << "\n";
cout << fixed << setprecision(2);
cout << " The diameter of the small pizza is " << smallarea << " inches" " Price = $" << smallprice << " Per square Inch = " << smallinch << endl;
cout << "\n";
cout << " The diameter of the medium pizza is " << mediumarea << " inches" " Price = $" << mediumprice << " Per square Inch = " << mediuminch << endl;
cout << "\n";
cout << " The diameter of the large pizza is " << largearea << " inches" " Price = $" << largeprice << " Per square Inch = " << largeinch << endl;
cout << "\n";
}
| |