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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#include <iostream>
using namespace std;
const double PI = 3.14;
//Function Decleration
void userInputSize(double&, double&, double&);
//
void userInputPrice(double&, double&, double&);
double calculateRadious(double&, double&, double&);
double calculateArea(double&, double&, double&);
double calculatePrice(double&, double&, double&);
//CalculateBestDeal- Prints the size and price of the pizza
void calculateBestDeal(double, double);
int main(){
cout << "Enter the size and the price of the pizza" << endl;
cout << " Small Pizza varies between 5 to 7 inches " << endl;
cout << " Medium pizza varies between 8 to 10 inches " << endl;
cout << " Large pizza varies between 11 to 13 inches " << endl;
double sSize,
mSize,
lSize,
sPrice,
mPrice,
lPrice;
userInputSize(sSize, mSize, lSize);
cout << " Small pizza costs $12.90" << endl;
cout << " Medium pizza costs $13.40" << endl;
cout << " Large pizza costs $27.90" << endl;
userInputPrice(sPrice, mPrice, lPrice);
//calculateRadious- Will calculate the Radious of the Pizza
double sRadious=0.00,
mRadious=0.00,
lRadious=0.00;
calculateRadious(sRadious, mRadious, lRadious);
//calculateArea- Will calculate the area of the Pizza
double sArea,
mArea,
lArea;
calculateArea(sArea, mArea, lArea);
//calculatePrice- Will calculate the price per inch
double sPerInch,
mPerInch,
lPerInch;
calculatePrice(sPerInch, mPerInch, lPerInch);
//Calculate the best size and best price of the pizza
double bestPizzaSize=0.00,
bestPizzaPrice=0.00;
calculateBestDeal(bestPizzaSize, bestPizzaPrice);
system("pause");
return 0;
}
void userInputSize(double&small, double& medium, double& large){
do {
cout << "Enter the size of the small pizza (in inches):" << endl;
cin >> small;
cout << "Enter the size of the medium pizza (in inches):" << endl;
cin >> medium;
cout << "Enter the size of the large pizza (in inches):" << endl;
cin >> large;
} while ((!(small >= 5) || !(small <= 7)) && (!(medium >= 8) || !(medium <= 10)) && (!(large >= 11) || !(large <= 13)));
}
void userInputPrice(double&smallp, double&mediump, double&largep){
do{
cout << "Enter the price of the small pizza" << endl;
cin >> smallp;
cout << "Enter the price of the medium pizza" << endl;
cin >> mediump;
cout << "Enter the price of the large pizza" << endl;
cin >> largep;
} while (!(smallp == 12.90) && !(mediump == 13.40) && !(largep == 27.80));
}
double calculateRadious(double& newsRadious, double& newmRadious, double& newlRadious){
double sSize=0.00,
mSize=0.00,
lSize=0.00;
newsRadious = (sSize / 2);
newmRadious = (mSize / 2);
newlRadious = (lSize / 2);
return (newsRadious, newmRadious, newlRadious);
}
double calculateArea(double& newsArea, double& newmArea, double& newlArea){
double newsRadious=0.00,
newmRadious=0.00,
newlRadious=0.00;
newsArea = (PI* newsRadious) * 2;
newmArea = (PI * newmRadious) * 2;
newlRadious = (PI * newlRadious) * 2;
cout << " Area of a small pizza = " << newsArea << endl;
cout << " Area of a medioum size pizza = " << newmArea << endl;
cout << " Area of the large pizza = " << newlArea << endl;
return (newsArea, newmArea, newlArea);
}
double calculatePrice(double& sPrice, double& mPrice, double& lPrice){
double sPerInch=0.00,
mPerInch=0.00,
lPerInch=0.00,
sSize=0.00,
mSize=0.00,
lSize=0.00;
sPerInch = (sSize / sPrice);
mPerInch = (mSize / mPrice);
lPerInch = (lSize / lPrice);
cout << " Price per inch of the small Pizza = " << sPerInch << endl;
cout << " Price per inch of the medium Pizza = " << mPerInch << endl;
cout << " Price per inch of the large Pizza = " << lPerInch << endl;
return (sPrice, mPrice, lPrice);
}
void calculateBestDeal(double bestSize, double bestPrice){
double sSize=0.00,
mSize=0.00,
lSize=0.00,
sPrice=0.00,
mPrice=0.00,
lPrice=0.00,
sPerInch=0.00,
mPerInch=0.00,
lPerInch=0.00;
cout << " Enter diameter of a small pizza (in inches): " << sSize << endl;
cout << " Enter the price of small pizza " << sPrice << endl;
cout << " Enter diameter of a medium pizza (in inches): " << mSize << endl;
cout << " Enter the price of medium pizza " << mPrice << endl;
cout << " Enter diameter of a large pizza (in inches): " << lSize << endl;
cout << " Enter the price of large pizza " << lPrice << endl;
cout << " Small Pizza Diameter = " << sSize << " inches" " Price = " << sPrice << " Per square Inch = " << sPerInch << endl;
cout << " Medium Pizza Diameter = " << mSize << " inches" " Price = " << mPrice << " Per square Inch = " << mPerInch << endl;
cout << " Large Pizza Diameter = " << lSize << " inches" " Price = " << lPrice << " Per square Inch = " << lPerInch << endl;
}
|