-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (25 loc) · 1.04 KB
/
Copy pathmain.cpp
File metadata and controls
32 lines (25 loc) · 1.04 KB
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
#include <iomanip>
#include <iostream>
#include <cmath>
int main() {
const double pi = 3.14;
double orderedDiameter;
int orderedPizzas;
double substitutionDiameter;
double orderedArea;
double substitutionArea;
int minSubstitutionPizzas;
std::cout << "Enter the diameter of the ordered pizza (inches): ";
std::cin >> orderedDiameter;
std::cout << "Enter the number of ordered pizzas: ";
std::cin >> orderedPizzas;
std::cout << "Enter the diameter of the substitution pizza (inches): ";
std::cin >> substitutionDiameter;
orderedArea = orderedPizzas * pi * (orderedDiameter / 2.0) * (orderedDiameter / 2.0);
substitutionArea = pi * (substitutionDiameter / 2.0) * (substitutionDiameter / 2.0);
minSubstitutionPizzas = std::ceil(orderedArea / substitutionArea);
std::cout << "Total area ordered: " << orderedArea << " square inches\n";
std::cout << "Area per substitution pizza: " << substitutionArea << " square inches\n";
std::cout << "Minimum substitution pizzas needed: " << minSubstitutionPizzas << '\n';
return 0;
}