Guest User

Untitled

a guest
Nov 24th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10. char selection;
  11. int rowChosen = 0;
  12. int colChosen = 0;
  13. int seatNum = 0;
  14. float totalCost = 0;
  15.  
  16.  
  17. //theater menu
  18. do {
  19. cout << "MOVIE THEATER MENU" << endl;
  20. cout << "------------------" << endl;
  21. cout << "1) Sell a ticket" << endl;
  22. cout << "Q) Quit program" << endl;
  23. cout << "Please make a selection" << endl;
  24. cin >> selection;
  25.  
  26. if (selection == '1')
  27. {
  28. cout << "Please enter a row number and seat number for the ticket:n";
  29. cout << "Row # : ";
  30.  
  31. if (rowChosen < 0 || rowChosen > 14)
  32. {
  33. cout << "Please enter a row number between 0 and 14n";
  34. }
  35.  
  36. else
  37. {
  38. cin >> rowChosen;
  39. cin.ignore(15, 'n');
  40. }
  41.  
  42. cout << "Seat # : ";
  43.  
  44. if (colChosen < 0 || colChosen >19)
  45. {
  46. cout << "Please enter a column number between 0 and 19n";
  47. }
  48. else
  49. {
  50. cin >> colChosen;
  51. seatNum++; // count the seat that have been sold
  52. }
  53. cout << endl;
  54.  
  55. //if seat is already taken
  56. if (map[rowChosen][colChosen] == '#')
  57. {
  58. cout << "Sorry. The ticket is not available for this seat.n";
  59. continue; // start the loop again
  60. }
  61. else // selling the ticket
  62. map[rowChosen][colChosen] = '#';
  63. totalCost += rowCost[rowChosen];
  64. }
  65.  
  66. else if (selection == 'q' || selection == 'Q')
  67. {
  68. cout << "UPDATED SEATING CHART AND SALES INFO n";
  69. cout << "------------------------------------n";
  70. theaterSeats(map);
  71. cout << "TOTAL TICKETS SOLD: " << seatNum << endl;
  72. cout << fixed << setprecision(2) << "TOTAL REVENUE: $" << totalCost << endl;
  73. }
  74.  
  75. else if (selection != 'Q' && selection != 'q')
  76. {
  77. cout << "Invalid selection. Please try again" << endl;
  78. }
  79.  
  80.  
  81. } while (selection != 'Q' && selection != 'q');
  82.  
  83. cout << endl;
  84. cout << "You have chosen to quit the program. Thank you for using!" << endl;
  85.  
  86. system("PAUSE");
  87. return 0;
  88. }
Add Comment
Please, Sign In to add comment