Advertisement
MrsMcLead

Soda Party

Apr 22nd, 2014
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.72 KB | None | 0 0
  1. //============================================================================
  2. // Name        : SodaParty.cpp
  3. // Author      :
  4. // Version     :
  5. // Copyright   : Your copyright notice
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <iostream>
  10. using namespace std;
  11.  
  12. int numCups (int numPeople)
  13. {
  14. int numCups = numPeople * 3;
  15. return numCups;
  16. }
  17.  
  18.  
  19. int numStraws (int numPeople)
  20. {
  21. int numStraws = numPeople * 8;
  22. return numStraws;
  23. }
  24.  
  25. int numNapkins (int numPeople)
  26.     {
  27.     int numNapkins = numPeople * 5;
  28.     return numNapkins;
  29.     }
  30.  
  31. int amtIce(int numPeople)
  32. {
  33.     int amtIce = numPeople * 6;
  34.     return amtIce;
  35. }
  36.  
  37. int amtSoda(int numPeople)
  38. {
  39. int amtSoda = numPeople * 3 /9;
  40. return amtSoda;
  41. }
  42.  
  43. int numBagsOfStraws(int numPeople)
  44. {
  45.     int totalStraws = numStraws(numPeople);
  46.     int numBags = 0;
  47.     if(totalStraws%35==0)
  48.     {
  49.         numBags = totalStraws/35;
  50.     }
  51.     else
  52.     {
  53.         numBags = totalStraws/35+1;
  54.     }
  55.  
  56.     return numBags;
  57.  
  58. }
  59. int numBagsOfCups(int numPeople)
  60.  
  61. {
  62. int totalCups = numCups(numPeople);
  63. int BagsofCups = 0;
  64. if (totalCups%50==0)
  65. {
  66. BagsofCups = totalCups/50;
  67. }
  68.  
  69. else
  70. {
  71. BagsofCups = totalCups/50+1;
  72. }
  73. return BagsofCups;
  74. }
  75.  
  76. int numNapkinPackages(int numPeople)
  77. {
  78. int numNapkinPackages = 0;
  79. if (numNapkins(numPeople)%100==0)
  80. {
  81.  
  82. numNapkinPackages = numNapkins(numPeople) / 100;
  83. }
  84. else
  85. {
  86. numNapkinPackages = numNapkins(numPeople) / 100+1;
  87. }
  88. return numNapkinPackages;
  89. }
  90. int numberOfTraysOfIce(int numPeople)
  91. {
  92. int totalIce = amtIce(numPeople);
  93. int numTrays = 0;
  94. if(totalIce % 16 == 0)
  95. {
  96.        numTrays = totalIce/16;
  97. }
  98. else
  99.             {
  100.       numTrays = totalIce/16+1;
  101.     }
  102. return numTrays;
  103. }
  104.  
  105.  
  106. void printGroceryList(int numPeople)
  107. {
  108. cout << "The list of items you need " << endl;
  109. cout <<  numBagsOfCups(numPeople) << " bags of cups." << endl;
  110. cout << numNapkinPackages(numPeople) << " napkin packages." << endl;
  111. cout <<  numberOfTraysOfIce(numPeople) << " trays of ice." << endl;
  112. cout << numBagsOfStraws(numPeople) << " bags of straws." << endl;
  113. cout << amtSoda(numPeople) << " bottles of Soda." << endl;
  114. }
  115.  
  116.  
  117. void printGroceryBill(int numPeople)
  118. {
  119. double cupCost = numBagsOfCups(numPeople) * 2;
  120. double strawCost = numBagsOfStraws(numPeople) * 1.50;
  121. double sodaCost = amtSoda(numPeople) * 4;
  122. double napkinCost = numNapkinPackages(numPeople) * 1.50;
  123. double iceCost = numberOfTraysOfIce(numPeople) * .50;
  124. double totalCost = cupCost + strawCost + sodaCost + napkinCost + iceCost;
  125. cout << "The total cost of the grocery list is " << totalCost << " dollars." << endl;
  126. }
  127.  
  128.  
  129. int main() {
  130.     int numPeople = 12;
  131.     printGroceryList(numPeople);
  132.     cout <<endl<<endl;
  133.     printGroceryBill(numPeople);
  134.  
  135.     return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement