Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. // ConsoleApplication18.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. // FinalTest.cpp - This program processes ticket orders.
  3.  
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7. int main()
  8. {
  9. // Declare and initialize variables.
  10. const string BOX = "B";
  11. const string LOWER_CIRCLE = "L";
  12. const string UPPER_CIRCLE = "U";
  13. const string NONE = "N";
  14. string seatLocation;
  15. const double BOXC = 100.00;
  16. const double LOWERC = 75.00;
  17. const double UPPERC = 35.00;
  18. int boxTickets = 0;
  19. int lowerTickets = 0;
  20. int upperTickets = 0;
  21. double totalCost = 0;
  22. double ticketCost;
  23. int numTickets;
  24.  
  25.  
  26.  
  27. // Request seat location and list seat prices:
  28. cout << "Seat cost per ticket:" << endl;
  29. cout << "Box seats: $" << BOXC << endl;
  30. cout << "Lower Circle seats: $" << LOWERC << endl;
  31. cout << "Upper Circle seats: $" << UPPERC << endl;
  32. cout << "Using capital letters only, enter the seat location. B for a Box seat, L for a Lower Circle seat, U for an Upper Circle seat, or N to exit: ";
  33. cin >> seatLocation;
  34.  
  35. // Detail loop
  36. while (seatLocation != NONE)
  37. {
  38. while (seatLocation != BOX && seatLocation != LOWER_CIRCLE && seatLocation != UPPER_CIRCLE)
  39. {
  40. cout << "Invalid seat, please enter a valid seat location: " << endl;
  41. cin >> seatLocation;
  42. }
  43.  
  44. // Ticket Number prompt
  45. cout << "Enter the amount of tickets you want to purchase: ";
  46. cin >> numTickets;
  47.  
  48. // Calculation for ticket costs
  49. if (seatLocation == BOX)
  50. {
  51. ticketCost = numTickets * BOXC;
  52. boxTickets += numTickets;
  53. }
  54. else if (seatLocation == LOWER_CIRCLE)
  55. {
  56. ticketCost = numTickets * LOWERC;
  57. lowerTickets += numTickets;
  58. }
  59. else if (seatLocation == UPPER_CIRCLE)
  60. {
  61. ticketCost = numTickets * UPPERC;
  62. upperTickets += numTickets;
  63. }
  64.  
  65. // Display the current cost of the order
  66. cout << "You have requested a total of " << numTickets << " tickets with a total cost of $" << ticketCost << endl;
  67.  
  68. // Increment the current cost with the overall cost
  69. totalCost += ticketCost;
  70.  
  71. // Prompt for next seats to continue loop
  72. cout << "Enter the next seat location or enter N to exit: ";
  73. cin >> seatLocation;
  74. }
  75. // This is the end of the loop.
  76.  
  77.  
  78. // This is the work done in the endOfJob() function
  79. // Output
  80. cout << "You have ordered a total of: " << endl;
  81. cout << boxTickets << " Box tickets. " << endl;
  82. cout << lowerTickets << " Lower Circle tickets. " << endl;
  83. cout << upperTickets << " Upper Circle tickets " << endl;
  84. cout << "With a total cost of: $" << totalCost << endl;
  85.  
  86. return 0;
  87. } // end of program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement