fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. void getCustomer( string& custName, int& numAdults, int& numKids,
  8. char&mealType, char& roomType, string& weekday,
  9. float& deposit, ifstream& data);
  10. void custPay( int& adultMeal, int& childMeal, int& foodCost, int& tax, int& roomCost, int& bill, int& owe
  11. , float& surcharge, float& discount);
  12. float GetRoomCost (char roomType);
  13.  
  14. void printLines(int)
  15. {
  16. for (int i=0; i <= 50; i++)
  17. cout << "-";
  18. }
  19.  
  20. int main()
  21. {
  22.  
  23. int numAdults, numKids, adultMeal, childMeal, foodCost, bill, roomCost, owe;
  24. float deposit surcharge, discount;
  25. ifstream data;
  26. string custName, weekday;
  27. char mealType, roomType;
  28.  
  29. data.open("embassy.dat");
  30.  
  31. void getCustomer( string& custName, int& numAdults, int& numKids,
  32. char&mealType, char& roomType, string& weekday,
  33. float& deposit);
  34. while(!data.eof())
  35. {
  36. getline(data,custName);
  37. data>>numAdults>>numKids>>mealType>>roomType>>weekday>>deposit;
  38. data.close();
  39. if (!data.is_open())
  40. cout << "The data file could not be opened. The program is stopping.";
  41. return 1;
  42. }
  43.  
  44. //**************************************************************************************
  45. // Calculate payments
  46. //GetCustomer( variable)
  47. //while ( variable > 0 )
  48. printLines(50);
  49. cout << endl;
  50. cout << "Customer #" << endl;
  51.  
  52. printLines(50);
  53. cout << endl;
  54. cout << "Number of Adults served:" << numAdults << endl;
  55. cout << "Number of Children served:" << numKids << endl;
  56. cout << "Meal Type:" << mealType << endl;
  57. cout << "Cost of an Adult meal:" << adultMeal << endl;
  58. cout << "Cost of a Child meal:" << childMeal << endl;
  59. cout << "Total Food Cost:" << foodCost << endl;
  60. cout << "Tip and Tax:" << tax << endl;
  61. cout << "Room Cost:" << roomCost << endl;
  62. cout << "Surcharge for weekend:" << surcharge << endl;
  63.  
  64. printLines(50);
  65. cout << endl;
  66. cout << "TOTAL BILL:" << bill << endl;
  67. cout << "Deposit paid:" << deposit << endl;
  68.  
  69. printLines(50);
  70. cout << endl;
  71. cout << "YOU OWE" << owe << endl;
  72. cout << "If you pay within 10 days" << endl;
  73. cout << "Your discounted amount is:" << discount << endl;
  74.  
  75. printLines(50);
  76. cout << endl;
  77.  
  78. printLines(50);
  79. cout << endl;
  80. //**************************************************************************************
  81. void custPay( int& adultMeal)
  82. if (mealType == 'D' || mealType == 'd')
  83. {
  84. adultMeal = 15.80;
  85. childMeal = adultMeal * 0.6;
  86. }
  87. else if(mealType == 'S' or mealType == 's')
  88. {
  89. adultMeal = 11.75;
  90. childMeal = adultMeal * 0.6;
  91. }
  92. else
  93. cout << "Invalid meal type";
  94. //**************************************************************************************
  95. void custPay( int& foodCost)
  96. {
  97. foodCost = (adultMeal * numAdults) + (childMeal * numKids);
  98. }
  99. //**************************************************************************************
  100. void custPay( int& tax)
  101. {
  102. tax = foodcost * .18;
  103. }
  104. //**************************************************************************************
  105.  
  106. float GetRoomCost(char roomType)
  107. {
  108. switch(roomType)
  109. {
  110. case 'A': return: 55.00;
  111. case 'B': return: 75.00;
  112. case 'C': return: 85.00;
  113. case 'D': return: 100.00;
  114. case 'E': return: 130.00;
  115. default : cout << "Invalid" <<endl;
  116. cin >> roomCost;
  117. }
  118. }
  119. //**************************************************************************************
  120. void custPay( float& surcharge, string& weekday)
  121. {
  122. if(weekday == 'Saturday' || weekday == 'Friday' || weekday == 'Sunday')
  123. surcharge = 0.07 * (foodCost + roomCost);
  124. else
  125. surcharge = 0;
  126. }
  127. //**************************************************************************************
  128. void custPay( int& bill)
  129. {
  130. bill = roomType + tax + foodCost + surcharge;
  131. }
  132.  
  133. //**************************************************************************************
  134. void custPay( int& owe)
  135. {
  136. owe = bill - deposit;
  137. }
  138. //**************************************************************************************
  139. void custPay( float& discount)
  140. {
  141. if(bill < 100.00)
  142. discount = bill * 0.005
  143. else if(bill >= 100 && bill < 200)
  144. discount == bill * 0.015
  145. else if(bill >= 200 && bill < 400)
  146. discount == bill * 0.03
  147. else if(bill >= 400 && bill < 800)
  148. discount == bill * 0.04
  149. else if(bill >= 800)
  150. discount == bill * 0.05
  151. }
  152. //**************************************************************************************
  153. return 0;
  154.  
  155. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty