diff --git a/Makefile b/Makefile index e234100..edc4d3d 100644 --- a/Makefile +++ b/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 diff --git a/build/pizza b/build/pizza new file mode 100755 index 0000000..f6559e7 Binary files /dev/null and b/build/pizza differ diff --git a/src/pizza.cpp b/src/pizza.cpp new file mode 100644 index 0000000..e8e13c3 --- /dev/null +++ b/src/pizza.cpp @@ -0,0 +1,66 @@ +#include +#include +#include +#include + +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 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::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; +} \ No newline at end of file