Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication18.cpp : This file contains the 'main' function. Program execution begins and ends there.
- // FinalTest.cpp - This program processes ticket orders.
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- // Declare and initialize variables.
- const string BOX = "B";
- const string LOWER_CIRCLE = "L";
- const string UPPER_CIRCLE = "U";
- const string NONE = "N";
- string seatLocation;
- const double BOXC = 100.00;
- const double LOWERC = 75.00;
- const double UPPERC = 35.00;
- int boxTickets = 0;
- int lowerTickets = 0;
- int upperTickets = 0;
- double totalCost = 0;
- double ticketCost;
- int numTickets;
- // Request seat location and list seat prices:
- cout << "Seat cost per ticket:" << endl;
- cout << "Box seats: $" << BOXC << endl;
- cout << "Lower Circle seats: $" << LOWERC << endl;
- cout << "Upper Circle seats: $" << UPPERC << endl;
- 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: ";
- cin >> seatLocation;
- // Detail loop
- while (seatLocation != NONE)
- {
- while (seatLocation != BOX && seatLocation != LOWER_CIRCLE && seatLocation != UPPER_CIRCLE)
- {
- cout << "Invalid seat, please enter a valid seat location: " << endl;
- cin >> seatLocation;
- }
- // Ticket Number prompt
- cout << "Enter the amount of tickets you want to purchase: ";
- cin >> numTickets;
- // Calculation for ticket costs
- if (seatLocation == BOX)
- {
- ticketCost = numTickets * BOXC;
- boxTickets += numTickets;
- }
- else if (seatLocation == LOWER_CIRCLE)
- {
- ticketCost = numTickets * LOWERC;
- lowerTickets += numTickets;
- }
- else if (seatLocation == UPPER_CIRCLE)
- {
- ticketCost = numTickets * UPPERC;
- upperTickets += numTickets;
- }
- // Display the current cost of the order
- cout << "You have requested a total of " << numTickets << " tickets with a total cost of $" << ticketCost << endl;
- // Increment the current cost with the overall cost
- totalCost += ticketCost;
- // Prompt for next seats to continue loop
- cout << "Enter the next seat location or enter N to exit: ";
- cin >> seatLocation;
- }
- // This is the end of the loop.
- // This is the work done in the endOfJob() function
- // Output
- cout << "You have ordered a total of: " << endl;
- cout << boxTickets << " Box tickets. " << endl;
- cout << lowerTickets << " Lower Circle tickets. " << endl;
- cout << upperTickets << " Upper Circle tickets " << endl;
- cout << "With a total cost of: $" << totalCost << endl;
- return 0;
- } // end of program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement