Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char selection,marathon_type;
- const int full_marathon =10000, half_marathon =5000, seats =20, row =5, column =4;
- int seat_to_book, seat_to_vacate, gross_profit, seat_to_change;
- void main_menu()
- {
- //display menu
- cout << "========================"<< endl;
- cout << " THEATRE BOOKING "<< endl;
- cout << "========================"<< endl;
- cout << "1. View available seats"<< endl;
- cout << "2. Book seat"<< endl;
- cout << "3. Vacate seat"<< endl;
- cout << "4. Change marathon type"<< endl;
- cout << "5. Calculate gross profit"<< endl;
- cout << "6. Quit program"<< endl;
- }
- void print_seats()
- {
- int seats [5][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16},{17,18,19,20}};
- for (int row = 0; row < 5; row++)
- {
- for (int column=0; column<4; column++)
- {
- cout << seats[row][column] << " ";
- }
- cout << endl;
- }
- }
- void marathon_selection()
- {
- //selects the marathon type
- cout << "F - Full Marathon" << endl;
- cout << "H - Half Marathon" << endl;
- cin >> marathon_type;
- switch(toupper(marathon_type))
- {
- case 'F':
- gross_profit += full_marathon;
- cout << "=========================" << endl;
- cout << "Seat Booking Confirmation" << endl;
- cout << "=========================" << endl;
- cout << "Seat No: " << seat_to_book << endl;
- cout << "Marathon Type: Full Marathon" << endl;
- cout << "Cost: Ksh " << full_marathon << endl;
- break;
- case 'H':
- gross_profit += half_marathon;
- cout << "=========================" << endl;
- cout << "Seat Booking Confirmation" << endl;
- cout << "=========================" << endl;
- cout << "Seat No: " << seat_to_book << endl;
- cout << "Marathon Type: Half Marathon" << endl;
- cout << "Cost: Ksh " << half_marathon << endl;
- break;
- }
- main_menu();
- return;
- }
- void vacate_seats()
- {
- int seat_to_vacate;
- int array[20];
- cout << "Vacate seat number: ";
- cin >> seat_to_vacate;
- seat_to_vacate--;
- for (int i = seat_to_vacate; i < seats; i++)
- {
- int temp = array[i];
- array[i] = array[i+1];
- array[i+1] = temp;
- }
- for (int i = 0; i < seats - 1; i ++)
- {
- cout << array[i]<< " ";
- }
- }
- void book_seats()
- {
- //booking seats
- do
- {
- cout << "Enter the seat number to book: ";
- cin >> seat_to_book;
- while (seat_to_book >0 && seat_to_book <= 20)
- {
- cout << "Select the type of marathon you want: " << endl;
- marathon_selection();
- return;
- }
- }
- while (true);
- }
- void change_marathon_type()
- {
- char marathon_to_change;
- cout << "Enter the seat number you want to change the Marathon Type: ";
- cin >> seat_to_change;
- cout << "1. Full Marathon to Half Marathon" << endl;
- cout << "2. Half Marathon to Full Marathon" << endl;
- cin >> marathon_type;
- if (marathon_type == '1')
- {
- gross_profit-=half_marathon;
- cout << "Successfully changed from Full Marathon to Half Marathon" << endl;
- cout << "Price: " << half_marathon << endl;
- }
- else
- {
- gross_profit+=half_marathon;
- cout << "Successfully changed from Half Marathon to Full Marathon:" << endl;
- cout << "Price: " << endl;
- }
- }
- int DisplayGrossProfit()
- {
- if (gross_profit != 0)
- {
- cout << "The Gross Profit is Ksh: " << gross_profit << endl;
- }
- else
- { cout << "You have not sold out any tickets. The Gross profit is Ksh: 0 " << endl;
- }
- }
- int main ()
- {
- do
- {
- main_menu();
- cin >> selection;
- switch (selection)
- {
- case '1':
- print_seats();
- break;
- case '2':
- book_seats();
- break;
- case '3':
- vacate_seats();
- break;
- case '4':
- change_marathon_type();
- break;
- case '5':
- DisplayGrossProfit();
- break;
- case '6':
- return 0;
- default:
- cout << "Please choose a valid Option!" << endl;
- }
- }
- while (true);
- cout << "Exitting. Thank You for using the Program" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement