Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- char selection;
- int rowChosen = 0;
- int colChosen = 0;
- int seatNum = 0;
- float totalCost = 0;
- //theater menu
- do {
- cout << "MOVIE THEATER MENU" << endl;
- cout << "------------------" << endl;
- cout << "1) Sell a ticket" << endl;
- cout << "Q) Quit program" << endl;
- cout << "Please make a selection" << endl;
- cin >> selection;
- if (selection == '1')
- {
- cout << "Please enter a row number and seat number for the ticket:n";
- cout << "Row # : ";
- if (rowChosen < 0 || rowChosen > 14)
- {
- cout << "Please enter a row number between 0 and 14n";
- }
- else
- {
- cin >> rowChosen;
- cin.ignore(15, 'n');
- }
- cout << "Seat # : ";
- if (colChosen < 0 || colChosen >19)
- {
- cout << "Please enter a column number between 0 and 19n";
- }
- else
- {
- cin >> colChosen;
- seatNum++; // count the seat that have been sold
- }
- cout << endl;
- //if seat is already taken
- if (map[rowChosen][colChosen] == '#')
- {
- cout << "Sorry. The ticket is not available for this seat.n";
- continue; // start the loop again
- }
- else // selling the ticket
- map[rowChosen][colChosen] = '#';
- totalCost += rowCost[rowChosen];
- }
- else if (selection == 'q' || selection == 'Q')
- {
- cout << "UPDATED SEATING CHART AND SALES INFO n";
- cout << "------------------------------------n";
- theaterSeats(map);
- cout << "TOTAL TICKETS SOLD: " << seatNum << endl;
- cout << fixed << setprecision(2) << "TOTAL REVENUE: $" << totalCost << endl;
- }
- else if (selection != 'Q' && selection != 'q')
- {
- cout << "Invalid selection. Please try again" << endl;
- }
- } while (selection != 'Q' && selection != 'q');
- cout << endl;
- cout << "You have chosen to quit the program. Thank you for using!" << endl;
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment