Description Running a cinema theatre is no easy business. To help our friends, let's add statistics to your program. The stats will show the current income, total income, the number of available seats, and the percentage of occupancy.
In addition, our friends asked you to take care of a small inconvenience: it's not good when a user can buy a ticket that has already been purchased by another user. Let's fix this!
Objectives Now your menu should look like this:
- Show the seats
- Buy a ticket
- Statistics
- Exit When the item Statistics is chosen, your program should print the following information:
The number of purchased tickets; The number of purchased tickets represented as a percentage. Percentages should be rounded to 2 decimal places; Current income; The total income that shows how much money the theatre will get if all the tickets are sold. The rest of the menu items should work the same way as before, except the item Buy a ticket shouldn't allow a user to buy a ticket that has already been purchased.
If a user chooses an already taken seat, print That ticket has already been purchased! and ask them to enter different seat coordinates until they pick an available seat. Of course, you shouldn't allow coordinates that are out of bounds. If this happens, print Wrong input! and ask to enter different seat coordinates until the user picks an available seat.
Examples The greater-than symbol followed by a space (> ) represents the user input. Note that it's not part of the input.
Enter the number of rows:
6 Enter the number of seats in each row: 6
- Show the seats
- Buy a ticket
- Statistics
- Exit
3
Number of purchased tickets: 0 Percentage: 0.00% Current income: $0 Total income: $360
- Show the seats
- Buy a ticket
- Statistics
- Exit
2
Enter a row number:
1 Enter a seat number in that row: 1
Ticket price: $10
- Show the seats
- Buy a ticket
- Statistics
- Exit
3
Number of purchased tickets: 1 Percentage: 2.78% Current income: $10 Total income: $360
- Show the seats
- Buy a ticket
- Statistics
- Exit
2
Enter a row number:
1 Enter a seat number in that row: 1
That ticket has already been purchased!
Enter a row number:
10 Enter a seat number in that row: 20
Wrong input!
Enter a row number:
4 Enter a seat number in that row: 4
Ticket price: $10
- Show the seats
- Buy a ticket
- Statistics
- Exit
1
Cinema: 1 2 3 4 5 6 1 B S S S S S 2 S S S S S S 3 S S S S S S 4 S S S B S S 5 S S S S S S 6 S S S S S S
- Show the seats
- Buy a ticket
- Statistics
- Exit
3
Number of purchased tickets: 2 Percentage: 5.56% Current income: $20 Total income: $360
- Show the seats
- Buy a ticket
- Statistics
- Exit
0