Guest User

Untitled

a guest
Jan 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. void getSandwich(double &SANDWICH, double &subtotal, int &numberItems, string &topping1, string &sandwich1);
  7. void getToppings(string &topping1);
  8. void getSide(double &SIDE, double &subtotal, int &numberItems, string &sideItem);
  9. void getDrink(double &DRINK, double &subtotal, int &numberItems, string &drink);
  10.  
  11. int main ()
  12. {
  13. string name, topping1, sandwich1, sandwich2, orderstring, drink, sideItem;
  14. double subtotal = 0.0, tax = 0.0, total = 0.0, SIDE = 1.25, DRINK = 0.85, SANDWICH = 4.00;
  15. int numberItems = 0;
  16. const double SALES_TAX = 0.07;
  17.  
  18. cout << "Enter your name: " << endl;
  19. cin >> name;
  20.  
  21. getSandwich(SANDWICH, subtotal, numberItems, topping1, sandwich1);
  22. getSandwich(SANDWICH, subtotal, numberItems, topping1, sandwich1);
  23. getSide(SIDE, subtotal, numberItems, sideItem);
  24. getDrink(DRINK, subtotal, numberItems, drink);
  25.  
  26. orderstring = "Sandwich: " + sandwich1 + "\n " + "Topping: " + topping1 + "\n" + "Sandwich: " + sandwich2 + "\n " + "Topping: " + topping1 + "\n" + "Side: " + sideItem + "\n" + "Drink: " + drink;
  27.  
  28. system("cls");
  29.  
  30. cout << orderstring << endl;
  31.  
  32. cout << "Number of Items: " << numberItems << endl;
  33.  
  34. cout << "Subtotal: $" << setprecision(2) << fixed << subtotal << endl;
  35.  
  36. tax = subtotal * SALES_TAX;
  37. cout << setprecision(2) << fixed << "Tax: $" << tax << endl;
  38.  
  39. total = subtotal + tax;
  40. cout << "Total: $" << setprecision(2) << fixed << total << endl;
  41.  
  42. cout << "Thank you, " << name << "!" << endl;
  43.  
  44. system("pause");
  45. return 0;
  46. }
  47.  
  48. void getSandwich(double &SANDWICH, double &subtotal, int &numberItems, string &topping1, string &sandwich1, string &sandwich2)
  49. {
  50. cout << "Sandwich: " << endl;
  51. cin >> sandwich1;
  52. cin >> sandwich2;
  53. subtotal = subtotal + SANDWICH;
  54. numberItems++;
  55.  
  56. getToppings(topping1);
  57. }
  58.  
  59. void getToppings(string &topping1)
  60. {
  61. cout << "Topping on Sandwich: " << endl;
  62. cin >> topping1;
  63. }
  64.  
  65. void getSide(double &SIDE, double &subtotal, int &numberItems, string &sideItem)
  66. {
  67. cout << "Side Item: " << endl;
  68. cin >> sideItem;
  69. subtotal = subtotal + SIDE;
  70. numberItems++;
  71. }
  72.  
  73. void getDrink(double &DRINK, double &subtotal, int &numberItems, string &drink)
  74. {
  75. cout << "Drink: " << endl;
  76. cin >> drink;
  77. subtotal = subtotal + DRINK;
  78. numberItems++;
  79. }
Add Comment
Please, Sign In to add comment