-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
54 lines (42 loc) · 1.72 KB
/
main.cpp
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
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
int main () {
const double PI = 3.14159265;
int numGuests;
int numLarge;
int numMedium;
int numSmall;
const int numLargeFed = 9;
const int numMediumFed = 5;
const int numSmallFed = 2;
const int radiusLarge = 12;
const int radiusMedium = 9;
const int radiusSmall = 7;
double totalArea;
double areaPerGuest;
int tipPercent;
const double priceLarge = 15.78;
const double priceMedium = 13.25;
const double priceSmall = 8.39;
double subtotalCost;
double totalCost;
cout << "Please enter the number of guests: ";
cin >> numGuests;
cout << endl;
numLarge = numGuests / numLargeFed;
numMedium = (numGuests % numLargeFed) / numMediumFed;
numSmall = ((numGuests % numLargeFed) % numMediumFed) / numSmallFed;
cout << numLarge << " large pizzas, " << numMedium << " medium pizzas, and " << numSmall << " small pizzas will be needed." << endl << endl;
totalArea = ( numLarge * (PI * pow( radiusLarge, 2 ))) + ( numMedium * (PI * pow( radiusMedium, 2 ))) + ( numSmall * (PI * pow( radiusSmall, 2 )));
areaPerGuest = totalArea / numGuests;
cout << "A total of " << totalArea << " square inches of pizza will be purchased (" << areaPerGuest << " per guest)." << endl << endl;
cout << "Please enter the tip as a percentage (i.e. 10 means 10%): ";
cin >> tipPercent;
cout << endl;
subtotalCost = (numLarge * priceLarge) + (numMedium * priceMedium) + (numSmall * priceSmall);
totalCost = subtotalCost + (subtotalCost * (static_cast<double>(tipPercent) / 100));
cout << "The total cost of the event will be: $" << round(totalCost) << endl;
return 0;
}