idk
This commit is contained in:
parent
636529ec05
commit
7a14b8ed70
8
Makefile
8
Makefile
@ -2,6 +2,10 @@ setup:
|
||||
mkdir build
|
||||
sheet0:
|
||||
g++ src/sheet0.cpp -o ./build/sheet0
|
||||
run: sheet0
|
||||
chmod +x build/
|
||||
chmod +x build/sheet0
|
||||
build/sheet0
|
||||
|
||||
pizza:
|
||||
g++ src/pizza.cpp -o ./build/pizza
|
||||
chmod +x build/pizza
|
||||
build/pizza
|
||||
|
BIN
build/pizza
Executable file
BIN
build/pizza
Executable file
Binary file not shown.
66
src/pizza.cpp
Normal file
66
src/pizza.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
const double pi = 2*std::acos(0.0);
|
||||
int diameter_single, diameter_family;
|
||||
// int price_single, price_family;
|
||||
float area_single, area_family;
|
||||
float family_to_single_quotient;
|
||||
std::map<std::string, float> orders;
|
||||
bool ordering = true;
|
||||
std::string variety;
|
||||
float amount;
|
||||
|
||||
//std::cout << "Please specify the price of a single pizza in cents: ";
|
||||
//std::cin >> price_single;
|
||||
std::cout << "Please specify the diameter of a single Pizza in cm: ";
|
||||
std::cin >> diameter_single;
|
||||
|
||||
//std::cout << "Please specify the price of a family pizza in cents: ";
|
||||
//std::cin >> price_family;
|
||||
std::cout << "Please specify the diameter of a family Pizza in cm: ";
|
||||
std::cin >> diameter_family;
|
||||
|
||||
area_single = pi*diameter_single*diameter_single/4;
|
||||
area_family = pi*diameter_family*diameter_family/4;
|
||||
family_to_single_quotient = area_family/area_single;
|
||||
|
||||
std::cout << "The Family Pizza has " << family_to_single_quotient << " times more area than a single pizza.\n";
|
||||
|
||||
std::cout << "Please specify the amount of each variety.\n Enter \"DONE\" in caps to finish.\n";
|
||||
while(ordering)
|
||||
{
|
||||
std::cout << "Variety: ";
|
||||
std::cin >> variety;
|
||||
if(variety == "DONE")
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << "Amount: ";
|
||||
std::cin >> amount;
|
||||
|
||||
orders[variety] = amount;
|
||||
}
|
||||
|
||||
std::map<std::string, float>::iterator itr;
|
||||
|
||||
for(itr = orders.begin(); itr != orders.end(); itr++)
|
||||
{
|
||||
float amount = (itr->second)/family_to_single_quotient;
|
||||
if(amount<1)
|
||||
{
|
||||
std::cout << itr -> first << ": " << itr -> second << " single pizza(s).\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << itr -> first << ": " << amount << " family pizza(s).\n";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user