Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.21 KB | None | 0 0
  1. // Cis215 ch4 programming assignment
  2. #include <iostream>
  3. #include <string>
  4. #include <iomanip>
  5. #include <cstdlib>
  6. #include <stdlib.h>
  7. #include <fstream>
  8.  
  9. using namespace std;
  10.  
  11.  
  12. int main()
  13. {
  14.     string server;
  15.     double ricky;
  16.     double newbill = 0;
  17.     int pick = 5;
  18.     int items;
  19.     int test = 0;
  20.     int choice, total = 0;
  21.     int dow;
  22.     int bonus;
  23.     int flag = 0;
  24.     double numMeals;
  25.     double bill = 0.0;
  26.     double newtax = 0;
  27.     double tip;
  28.     double tip_precentage, newtip;
  29.     double tax = 0.09;
  30.     double totalbill;
  31.     double totaldue;
  32.     double newtotal;
  33.     const string inn = "The Green Dragon Inn";
  34.     const double rate = 0.09;
  35.     do {
  36.        
  37.         // choices  
  38.         cout << endl;
  39.         cout << "Main Menu\n";
  40.         cout << "1) Food Menu\n";
  41.         cout << "2) Calculate Bill\n";
  42.         cout << "3) Exit\n";
  43.         cout << "Please enter your choice (1- 3):\n";
  44.         cin >> choice;
  45.  
  46.        
  47.         while (pick >= 5 )
  48.         {
  49.             switch (choice)
  50.             {
  51.             case 1:
  52.                 cout << endl;
  53.                 cout << "Slice of Pizza 1.99\n";
  54.                 cout << "Bacon Burger 5.99\n";
  55.                 cout << "Chicken Tenders 7.99 \n";
  56.                 cout << "Rack of Ribs 12.99\n";
  57.                 cout << "Chicken Salad 3.99\n";
  58.                 cout << "Fries 2.99\n";
  59.                 cout << "BBQ Sandwich 4.99\n";
  60.                 cout << "Loaded Baked Potato 6.99\n";
  61.  
  62.                 cout << endl;
  63.                 cout << "please pick day of the week\n" << endl;
  64.                 cout << "1) Monday\n";
  65.                 cout << "2) Tuesday\n";
  66.                 cout << "3) Wednesday\n";
  67.                 cout << "4) Thursday\n";
  68.                 cout << "5) Friday\n";
  69.                 cout << "6) Saturday\n";
  70.                 cout << "7) Sunday\n";
  71.  
  72.                 cin >> dow;
  73.                 if (dow == 1)
  74.                 {
  75.                     cout << "Special for Monday - free fries with a BBQ Sandwich" << endl;
  76.                     cout << endl;
  77.                 }
  78.                 else if (dow == 2) {
  79.                     cout << "Special for Tuesday is $1.00 off a rack of ribs\n";
  80.                     cout << endl;
  81.                 }
  82.                 else if (dow == 3) {
  83.                     cout << "Special for Wednesday is $1.00 off loaded baked potato\n";
  84.                     cout << endl;
  85.                 }
  86.                 else if (dow == 4) {
  87.                     cout << "Special for Thursday is $1.00 off chicken tenders\n";
  88.                     cout << endl;
  89.                 }
  90.                 else if (dow == 5) {
  91.                     cout << "Special for Friday is TGIF free slice of pizza with every order\n";
  92.                     cout << endl;
  93.                 }
  94.                 else if (dow == 6) {
  95.                     cout << "No Special for today but thanks for dining with us!\n";
  96.                     cout << endl;
  97.                 }
  98.                 else if (dow == 7) {
  99.                     cout << "No Special for today but thanks for dining with us!\n";
  100.                     cout << endl;
  101.                 }
  102.                 break;
  103.  
  104.  
  105.  
  106.  
  107.  
  108.             case 2:
  109.                 cin.ignore();
  110.                 cout << "servers name:" << endl;
  111.                 getline(cin, server);
  112.  
  113.                 // enter bill and tip
  114.                 cout << " how many meals did you order\n";
  115.                 cin >> items;
  116.                 for (int count = 1; count <= items; count++)
  117.                 {
  118.                     double sales;
  119.                     cout << "enter sales" << count << ":  ";
  120.                     cin >> sales;
  121.                     bill += sales;
  122.                 }
  123.  
  124.                 cout << fixed << showpoint << setprecision(2);
  125.                 cout << "total sales is $" << total << endl;
  126.                 cout << "Please select a tip amount\n";
  127.                 cout << endl;
  128.                 cout << "1) 20%\n";
  129.                 cout << "2) 18%\n";
  130.                 cout << "3) 15%\n";
  131.                 cout << "4) 12%\n";
  132.                 cout << "5) 10%\n";
  133.                 cout << "6) other\n";
  134.                 cin >> test;
  135.                 break;
  136.             case 3:
  137.                 cout << "good bye!\n";
  138.                 break;
  139.  
  140.             default: cout << "not a vaild choice restart program and try again.\n";
  141.                 cout << endl;
  142.             }
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.             // switch statement
  154.             switch (test)
  155.             {
  156.             case 1:
  157.                 tip_precentage = 20;
  158.                 cout << "_____________________________";
  159.                 cout << "You entered the following:\n";
  160.                 cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
  161.                 cout << "Tip:" << setw(28) << static_cast<int>(0.20 * 100) << "%" << endl;
  162.                 cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
  163.                 tax = bill * rate;
  164.                 tip = (bill + tax) / 100 * 20;
  165.                 totalbill = tax + bill + tip;
  166.                 cout << setprecision(2) << fixed;
  167.                 cout << "_______________________________" << endl;
  168.                 ricky = (bill * 0.05);
  169.                 newbill = bill - ricky;
  170.                 newtax = newbill * rate;
  171.                 newtip = (newbill + newtax) * .20;
  172.                 newtotal = newbill + newtax + newtip;
  173.  
  174.  
  175.  
  176.                 if (bill > 40.00 && tip_precentage > 12.00)
  177.                 {
  178.  
  179.                     cout << "you have a 5% discount\n";
  180.                     cout << "tax" << setw(28) << "$" << newtax << endl;
  181.                     cout << "tip" << setw(28) << "$" << newtip << endl;
  182.                     cout << endl;
  183.                     cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
  184.                     cout << "____________________________\n";
  185.                     cout << "Total due:" << setw(21) << "$" << newtotal << endl;
  186.                     cout << endl;
  187.                     cout << "Thanks for dining with us at" << " " << inn;
  188.                     cout << endl;
  189.                     cout << endl;
  190.                     srand(time(NULL));
  191.                     cout << "Your table number is " << rand() % 20 << endl;
  192.                     cout << endl;
  193.                     cout << "You were served by:" << " " << server << endl;
  194.                     cout << endl;
  195.                     cout << "Thanks for dining with us!" << endl;
  196.                     cout << endl;
  197.                     char letter;
  198.                     cin.ignore();
  199.                     cout << "Press Enter to continue";
  200.                     cin.get(letter);
  201.  
  202.  
  203.                 }
  204.                 else
  205.                 {
  206.                     cout << "tax" << setw(28) << "$" << tax << endl;
  207.                     cout << "tip" << setw(28) << "$" << tip << endl;
  208.                     cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
  209.                     cout << endl;
  210.                     cout << "Thanks for dining with us at" << " " << inn;
  211.                     cout << endl;
  212.                     cout << endl;
  213.                     srand(time(NULL));
  214.                     cout << "Your table number is " << rand() % 20 << endl;
  215.                     cout << endl;
  216.                     cout << "You were served by:" << " " << server << endl;
  217.                     cout << endl;
  218.                     cout << "Thanks for dining with us!" << endl;
  219.                     cout << endl;
  220.                     char letter;
  221.                     cin.ignore();
  222.                     cout << "Press Enter to continue";
  223.                     cin.get(letter);
  224.                     break;
  225.  
  226.                 }
  227.  
  228.  
  229.  
  230.                 break;
  231.             case 2:
  232.                 tip_precentage = 18;
  233.                 cout << "_____________________________";
  234.                 cout << "You entered the following:\n";
  235.                 cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
  236.                 cout << "Tip:" << setw(28) << static_cast<int>(0.18 * 100) << "%" << endl;
  237.                 cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
  238.                 tax = bill * rate;
  239.                 tip = (bill + tax) / 100 * 18;
  240.                 totalbill = tax + bill + tip;
  241.                 cout << setprecision(2) << fixed;
  242.                 cout << "_______________________________" << endl;
  243.                 ricky = (bill * 0.05);
  244.                 newbill = bill - ricky;
  245.                 newtax = newbill * rate;
  246.                 newtip = (newbill + newtax) * .18;
  247.                 newtotal = newbill + newtax + newtip;
  248.  
  249.                 if (bill > 40.00 && tip_precentage > 12.00)
  250.                 {
  251.                     cout << "you have a 5% discount\n";
  252.                     cout << "tax" << setw(28) << "$" << newtax << endl;
  253.                     cout << "tip" << setw(28) << "$" << newtip << endl;
  254.                     cout << endl;
  255.                     cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
  256.                     cout << "____________________________\n";
  257.                     cout << "Total due:" << setw(21) << "$" << newtotal << endl;
  258.                     cout << endl;
  259.                     cout << "Thanks for dining with us at" << " " << inn;
  260.                     cout << endl;
  261.                     cout << endl;
  262.                     srand(time(NULL));
  263.                     cout << "Your table number is " << rand() % 20 << endl;
  264.                     cout << endl;
  265.                     cout << "You were served by:" << " " << server << endl;
  266.                     cout << endl;
  267.                     cout << "Thanks for dining with us!" << endl;
  268.                     cout << endl;
  269.                     char letter;
  270.                     cin.ignore();
  271.                     cout << "Press Enter to continue";
  272.                     cin.get(letter);
  273.  
  274.  
  275.                 }
  276.                 else
  277.                 {
  278.  
  279.                     cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
  280.                     cout << "tax" << setw(28) << "$" << tax << endl;
  281.                     cout << "tip" << setw(28) << "$" << tip << endl;
  282.                     cout << endl;
  283.                     cout << "Thanks for dining with us at" << " " << inn;
  284.                     cout << endl;
  285.                     cout << endl;
  286.                     srand(time(NULL));
  287.                     cout << "Your table number is " << rand() % 20 << endl;
  288.                     cout << endl;
  289.                     cout << "You were served by:" << " " << server << endl;
  290.                     cout << endl;
  291.                     cout << "Thanks for dining with us!" << endl;
  292.                     cout << endl;
  293.                     char letter;
  294.                     cin.ignore();
  295.                     cout << "Press Enter to continue";
  296.                     cin.get(letter);
  297.                     break;
  298.  
  299.                 }
  300.  
  301.  
  302.  
  303.  
  304.  
  305.             case 3:
  306.                 tip_precentage = 15;
  307.                 cout << "_____________________________";
  308.                 cout << "You entered the following:\n";
  309.                 cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
  310.                 cout << "Tip:" << setw(28) << static_cast<int>(0.15 * 100) << "%" << endl;
  311.                 cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
  312.                 tax = bill * rate;
  313.                 tip = (bill + tax) / 100 * 15;
  314.                 totalbill = tax + bill + tip;
  315.                 cout << setprecision(2) << fixed;
  316.                 cout << "_______________________________" << endl;
  317.                 ricky = (bill * 0.05);
  318.                 newbill = bill - ricky;
  319.                 newtax = newbill * rate;
  320.                 newtip = (newbill + newtax) * .15;
  321.                 newtotal = newbill + newtax + newtip;
  322.  
  323.                 if (bill > 40.00 && tip_precentage > 12.00)
  324.                 {
  325.                     cout << "you have a 5% discount\n";
  326.                     cout << "tax" << setw(28) << "$" << newtax << endl;
  327.                     cout << "tip" << setw(28) << "$" << newtip << endl;
  328.                     cout << endl;
  329.                     cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
  330.                     cout << "____________________________\n";
  331.                     cout << "Total due:" << setw(21) << "$" << newtotal << endl;
  332.                     cout << endl;
  333.                     cout << "Thanks for dining with us at" << " " << inn;
  334.                     cout << endl;
  335.                     cout << endl;
  336.                     srand(time(NULL));
  337.                     cout << "Your table number is " << rand() % 20 << endl;
  338.                     cout << endl;
  339.                     cout << "You were served by:" << " " << server << endl;
  340.                     cout << endl;
  341.                     cout << "Thanks for dining with us!" << endl;
  342.                     cout << endl;
  343.                     char letter;
  344.                     cin.ignore();
  345.                     cout << "Press Enter to continue";
  346.                     cin.get(letter);
  347.  
  348.  
  349.                 }
  350.                 else
  351.                 {
  352.  
  353.                     cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
  354.                     cout << "tax" << setw(28) << "$" << tax << endl;
  355.                     cout << "tip" << setw(28) << "$" << tip << endl;
  356.                     cout << endl;
  357.                     cout << "Thanks for dining with us at" << " " << inn;
  358.                     cout << endl;
  359.                     cout << endl;
  360.                     srand(time(NULL));
  361.                     cout << "Your table number is " << rand() % 20 << endl;
  362.                     cout << endl;
  363.                     cout << "You were served by:" << " " << server << endl;
  364.                     cout << endl;
  365.                     cout << "Thanks for dining with us!" << endl;
  366.                     cout << endl;
  367.                     char letter;
  368.                     cin.ignore();
  369.                     cout << "Press Enter to continue";
  370.                     cin.get(letter);
  371.  
  372.                     break;
  373.                 }
  374.  
  375.  
  376.  
  377.             case 4:
  378.                 tip_precentage = 12;
  379.                 cout << "_____________________________";
  380.                 cout << "You entered the following:\n";
  381.                 cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
  382.                 cout << "Tip:" << setw(28) << static_cast<int>(0.12 * 100) << "%" << endl;
  383.                 cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
  384.                 tax = bill * rate;
  385.                 tip = (bill + tax) / 100 * 12;
  386.                 totalbill = tax + bill + tip;
  387.                 cout << setprecision(2) << fixed;
  388.                 cout << "_______________________________" << endl;
  389.                 ricky = (bill * 0.05);
  390.                 newbill = bill - ricky;
  391.                 newtax = newbill * rate;
  392.                 newtip = (newbill + newtax) * .12;
  393.                 newtotal = newbill + newtax + newtip;
  394.  
  395.                 if (bill > 40.00 && tip_precentage > 12.00)
  396.                 {
  397.                     cout << "you have a 5% discount\n";
  398.                     cout << "tax" << setw(28) << "$" << newtax << endl;
  399.                     cout << "tip" << setw(28) << "$" << newtip << endl;
  400.                     cout << endl;
  401.                     cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
  402.                     cout << "____________________________\n";
  403.                     cout << "Total due:" << setw(21) << "$" << newtotal << endl;
  404.                     cout << endl;
  405.                     cout << "Thanks for dining with us at" << " " << inn;
  406.                     cout << endl;
  407.                     cout << endl;
  408.                     srand(time(NULL));
  409.                     cout << "Your table number is " << rand() % 20 << endl;
  410.                     cout << endl;
  411.                     cout << "You were served by:" << " " << server << endl;
  412.                     cout << endl;
  413.                     cout << "Thanks for dining with us!" << endl;
  414.                     cout << endl;
  415.                     char letter;
  416.                     cin.ignore();
  417.                     cout << "Press Enter to continue";
  418.                     cin.get(letter);;
  419.  
  420.  
  421.                 }
  422.  
  423.                 else
  424.                 {
  425.  
  426.                     cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
  427.                     cout << "tax" << setw(28) << "$" << tax << endl;
  428.                     cout << "tip" << setw(28) << "$" << tip << endl;
  429.                     cout << endl;
  430.                     cout << "Thanks for dining with us at" << " " << inn;
  431.                     cout << endl;
  432.                     cout << endl;
  433.                     srand(time(NULL));
  434.                     cout << "Your table number is " << rand() % 20 << endl;
  435.                     cout << endl;
  436.                     cout << "You were served by:" << " " << server << endl;
  437.                     cout << endl;
  438.                     cout << "Thanks for dining with us!" << endl;
  439.                     cout << endl;
  440.                     char letter;
  441.                     cin.ignore();
  442.                     cout << "Press Enter to continue";
  443.                     cin.get(letter);
  444.                     break;
  445.                 }
  446.  
  447.  
  448.  
  449.  
  450.  
  451.             case 5:
  452.                 tip_precentage = 10;
  453.                 cout << "_____________________________";
  454.                 cout << "You entered the following:\n";
  455.                 cout << "Bill Amount:" << setw(19) << "$" << bill << endl;
  456.                 cout << "Tip:" << setw(28) << static_cast<int>(0.10 * 100) << "%" << endl;
  457.                 cout << "Tax rate is:" << setw(20) << static_cast<int> (0.09 * 100) << "%" << endl;
  458.                 tax = bill * rate;
  459.                 tip = (bill + tax) / 100 * 10;
  460.                 totalbill = tax + bill + tip;
  461.                 cout << setprecision(2) << fixed;
  462.                 cout << "_______________________________" << endl;
  463.                 ricky = (bill * 0.05);
  464.                 newbill = bill - ricky;
  465.                 newtax = newbill * rate;
  466.                 newtip = (newbill + newtax) * .10;
  467.                 newtotal = newbill + newtax + newtip;
  468.  
  469.                 if (bill > 40.00 && tip_precentage > 12.00)
  470.                 {
  471.                     cout << "you have a 5% discount\n";
  472.                     cout << "tax" << setw(28) << "$" << newtax << endl;
  473.                     cout << "tip" << setw(28) << "$" << newtip << endl;
  474.                     cout << endl;
  475.                     cout << "your new bill amount:" << setw(10) << "$" << newbill << endl;
  476.                     cout << "____________________________\n";
  477.                     cout << "Total due:" << setw(21) << "$" << newtotal << endl;
  478.                     cout << endl;
  479.                     cout << "Thanks for dining with us at" << " " << inn;
  480.                     cout << endl;
  481.                     cout << endl;
  482.                     srand(time(NULL));
  483.                     cout << "Your table number is " << rand() % 20 << endl;
  484.                     cout << endl;
  485.                     cout << "You were served by:" << " " << server << endl;
  486.                     cout << endl;
  487.                     cout << "Thanks for dining with us!" << endl;
  488.                     cout << endl;
  489.                     char letter;
  490.                     cin.ignore();
  491.                     cout << "Press Enter to continue";
  492.                     cin.get(letter);
  493.  
  494.  
  495.  
  496.                 }
  497.                 else
  498.                 {
  499.  
  500.                     cout << "Total Bill:" << setw(20) << "$" << totalbill << endl;
  501.                     cout << "tax" << setw(28) << "$" << tax << endl;
  502.                     cout << "tip" << setw(28) << "$" << tip << endl;
  503.                     cout << endl;
  504.                     cout << "Thanks for dining with us at" << " " << inn;
  505.                     cout << endl;
  506.                     cout << endl;
  507.                     srand(time(NULL));
  508.                     cout << "Your table number is " << rand() % 20 << endl;
  509.                     cout << endl;
  510.                     cout << "You were served by:" << " " << server << endl;
  511.                     cout << endl;
  512.                     cout << "Thanks for dining with us!" << endl;
  513.                     cout << endl;
  514.                     char letter;
  515.                     cin.ignore();
  516.                     cout << "Press Enter to continue";
  517.                     cin.get(letter);
  518.                     break;
  519.  
  520.                 }
  521.  
  522.  
  523.  
  524.  
  525.             case 6:
  526.  
  527.                 cout << "Enter Tip precentage:%" << setw(10);
  528.                 cin >> tip_precentage;
  529.                 tax = static_cast<int>(tax * 100);
  530.                 cout << "Your Tax Rate Is:" << setw(10) << tax << "%" << endl;
  531.                 cout << setprecision(2) << fixed;
  532.                 cout << "Bill Amount:$" << setw(10) << bill << endl;
  533.                 tip_precentage = static_cast<int>(tip_precentage);
  534.                 cout << "Tip Percentage:" << setw(10) << tip_precentage;
  535.                 cout << endl;
  536.                 tax = bill * rate;
  537.                 cout << "Tax Amount:$" << setw(10) << tax << endl;
  538.  
  539.  
  540.  
  541.                 tip = (tax + bill) / 100 * tip_precentage;
  542.                 cout << "Tip Amount:$" << setw(10) << tip << endl;
  543.                 cout << endl;
  544.                 totaldue = tax += tip += bill;
  545.                 cout << "Total Due:$" << setw(10) << totaldue << endl;
  546.                 cout << endl;
  547.  
  548.  
  549.                 cout << "Thanks for dining with us at\n" << inn;
  550.                 cout << endl;
  551.                 cout << endl;
  552.                 srand(time(NULL));
  553.                 cout << "Your table number is " << rand() % 20;
  554.                 cout << endl;
  555.                 cout << "You were served by:\n" << server << endl;
  556.                 cout << endl;
  557.                 cout << "Thanks for dining with us!" << endl;
  558.                 cout << endl;
  559.                 char letter;
  560.                 cin.ignore();
  561.                 cout << "Press Enter to continue";
  562.                 cin.get(letter);
  563.                 break;
  564.             }
  565.  
  566.             cout << "do you want to see this again (Y or N)";
  567.             cin >> pick;
  568.            
  569.  
  570.  
  571.            
  572.                
  573.         }
  574.        
  575.    
  576.            
  577.  
  578.  
  579.  
  580.    
  581.     }while (choice != 3);
  582.        
  583.    
  584.    
  585.     system("pause");
  586.         return 0;
  587.  
  588.    
  589.  
  590. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement