Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================
- // Name : SodaParty.cpp
- // Author :
- // Version :
- // Copyright : Your copyright notice
- // Description : Hello World in C++, Ansi-style
- //============================================================================
- #include <iostream>
- using namespace std;
- int numCups (int numPeople)
- {
- int numCups = numPeople * 3;
- return numCups;
- }
- int numStraws (int numPeople)
- {
- int numStraws = numPeople * 8;
- return numStraws;
- }
- int numNapkins (int numPeople)
- {
- int numNapkins = numPeople * 5;
- return numNapkins;
- }
- int amtIce(int numPeople)
- {
- int amtIce = numPeople * 6;
- return amtIce;
- }
- int amtSoda(int numPeople)
- {
- int amtSoda = numPeople * 3 /9;
- return amtSoda;
- }
- int numBagsOfStraws(int numPeople)
- {
- int totalStraws = numStraws(numPeople);
- int numBags = 0;
- if(totalStraws%35==0)
- {
- numBags = totalStraws/35;
- }
- else
- {
- numBags = totalStraws/35+1;
- }
- return numBags;
- }
- int numBagsOfCups(int numPeople)
- {
- int totalCups = numCups(numPeople);
- int BagsofCups = 0;
- if (totalCups%50==0)
- {
- BagsofCups = totalCups/50;
- }
- else
- {
- BagsofCups = totalCups/50+1;
- }
- return BagsofCups;
- }
- int numNapkinPackages(int numPeople)
- {
- int numNapkinPackages = 0;
- if (numNapkins(numPeople)%100==0)
- {
- numNapkinPackages = numNapkins(numPeople) / 100;
- }
- else
- {
- numNapkinPackages = numNapkins(numPeople) / 100+1;
- }
- return numNapkinPackages;
- }
- int numberOfTraysOfIce(int numPeople)
- {
- int totalIce = amtIce(numPeople);
- int numTrays = 0;
- if(totalIce % 16 == 0)
- {
- numTrays = totalIce/16;
- }
- else
- {
- numTrays = totalIce/16+1;
- }
- return numTrays;
- }
- void printGroceryList(int numPeople)
- {
- cout << "The list of items you need " << endl;
- cout << numBagsOfCups(numPeople) << " bags of cups." << endl;
- cout << numNapkinPackages(numPeople) << " napkin packages." << endl;
- cout << numberOfTraysOfIce(numPeople) << " trays of ice." << endl;
- cout << numBagsOfStraws(numPeople) << " bags of straws." << endl;
- cout << amtSoda(numPeople) << " bottles of Soda." << endl;
- }
- void printGroceryBill(int numPeople)
- {
- double cupCost = numBagsOfCups(numPeople) * 2;
- double strawCost = numBagsOfStraws(numPeople) * 1.50;
- double sodaCost = amtSoda(numPeople) * 4;
- double napkinCost = numNapkinPackages(numPeople) * 1.50;
- double iceCost = numberOfTraysOfIce(numPeople) * .50;
- double totalCost = cupCost + strawCost + sodaCost + napkinCost + iceCost;
- cout << "The total cost of the grocery list is " << totalCost << " dollars." << endl;
- }
- int main() {
- int numPeople = 12;
- printGroceryList(numPeople);
- cout <<endl<<endl;
- printGroceryBill(numPeople);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement