P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
20 20 30 30 40 40 30 30 20 20
20 30 30 40 50 50 40 30 30 20
30 40 50 50 50 50 50 50 40 30
(Note that there are 9 rows, and 10 columns).
Program Function
We will write a program that allows a user to pick a seat to purchase. The program will:
Program Design
You will have two classes in this program:
TheaterSeatTester Class
TheaterSeatSeller Class
Hi
Here are the two classes you will be needing, the program is working fine.checkout the sample output at the end.
----------------------------------------------------------------------------------------------------------------------------------------------------------
public class TheaterSeatSeller { private static int[][] seats = { {10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, {10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, {10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, {10, 10, 20, 20, 20, 20, 20, 20, 10, 10}, {10, 10, 20, 20, 20, 20, 20, 20, 10, 10}, {10, 10, 20, 20, 20, 20, 20, 20, 10, 10}, {20, 20, 30, 30, 40, 40, 30, 30, 20, 20}, {20, 30, 30, 40, 50, 50, 40, 30, 30, 20}, {30, 40, 50, 50, 50, 50, 50, 50, 40, 30}, }; public TheaterSeatSeller() { } public void printSeats() { for (int row = 0; row <= 8; row++) { for (int col = 0; col <= 9; col++) { System.out.printf("%4d", seats[row][col]); } System.out.println(); } } public boolean getByLoc(int row, int col) { if (1 <= row && row <= 10 && 1 <= col && col <= 11) { if (seats[row - 1][col - 1] != 0) { System.out.println("Seat Price: $" + seats[row - 1][col - 1]); System.out.println("Seat Booked successfully!"); seats[row - 1][col - 1] = 0; return true; } else { System.out.println("Seat already sold out"); return false; } } else { System.out.println("Enter valid row and col"); return false; } } public boolean getByPrice(int price) { for (int row = 8; row >= 0; row--) { for (int col = 9; col >= 0; col--) { if (seats[row][col] == price && seats[row][col] != 0) { System.out.println("Seat available at row: " + (row + 1) + " col: " + (col + 1)); System.out.println("Seat Booked successfully"); seats[row][col] = 0; return true; } } } System.out.println("No seat available at this price."); return false; } public boolean allSeatsSold() { int total = 0; for (int row = 0; row <= 8; row++) { for (int col = 0; col <= 9; col++) { total += seats[row][col]; } } return total == 0; } public boolean getBest() { for (int row = 8; row >= 0; row--) { for (int col = 9; col >= 0; col--) { if (seats[row][col] != 0) { System.out.println("Seat available at row: " + (row + 1) + " col: " + (col + 1)); System.out.println("Seat Booked successfully"); seats[row][col] = 0; return true; } } } System.out.println("No more seats available"); return false; } }
----------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner; public class TheaterSeatTester { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { TheaterSeatSeller theater = new TheaterSeatSeller(); while (!theater.allSeatsSold()) { System.out.println("[1] - Type to book seat by location"); System.out.println("[2] - Type to book seat by price"); System.out.println("[3] - Type to book seat by best"); System.out.println("[0] - Type to exit"); int choice = scanner.nextInt(); if (choice == 0) { System.out.println("Goodbye"); break; } else if (choice == 1) { System.out.print("Enter row: "); int row = scanner.nextInt(); System.out.println("Enter col: "); int col = scanner.nextInt(); theater.getByLoc(row, col); } else if (choice == 2) { System.out.print("Enter price - (10,20,30,40, or 50) "); int price = scanner.nextInt(); theater.getByPrice(price); } else if (choice == 3) { theater.getBest(); } theater.printSeats(); } } }
----------------------------------------------------------------------------------------------------------------------------------------------------------
thanks a lot!
P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:...
A theater seating chart is implemented as a two-dimensional array of ticket prices like presented below. Write a program that prompts the users to pick either a seat or a price. Mark sold seats by changing the price to zero. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price. Verify that the price is among those offered by the theater. 10 10 10 10 10 10...
Write pseudocode for a program where the seating map for a particular performance at a theater contains 70 rows of 100 seats each. Using an array where applicable, develop the pseudeocode for a program that allows a user to continuously enter each household size and then a) Allows a user to continuously enter a row number and seat number until they enter an appropriate sentinel value for the row number in order to stop entering input. Each time the user...
I need help fixing this code and adding a loop please. Here is the original problem: #include <iostream> using namespace std; //function to print seating chart void printSeatingChart(int **chart) { int i, j; cout << "\nROW\t"; for (i = 1; i <= 10; i++) { cout << i << "\t"; } cout << "\n-----------------------------------------------------------------------------------\n"; for (i = 8; i >= 0; i--) { cout << "\n" << i + 1 << "\t"; for (j = 0; j < 10; j++) ...
Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your program should display the following menu of alternatives: Please type 1 for "section A, $50/ticket" type 2 for "section B, $70/ticket", and type 3 for "section C, $80/ticket". If the user types 1, then your program should assign a seat in the A section (seats 1–50). If the user types 2, then your program should assign a seat in the B section (seats 51–100). If...
Can you help us!! Thank you! C++ Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...
Your assignment is to design a TicketManager class that can keep track of the number of seats available in a theater’s auditorium. The TicketManager class should have a two-Dimensional array, which has 15 rows and 30 columns for all the seats available in the auditorium, also an array of double to keep track of the price of tickets for each row. Each row has a different price. Use the following UML diagram to design the class: -------------------------------------------------------------------- + NUMROWS :...
The language is C++ for visual studio express 2013 for windows create a TicketManager class and a program that uses the class to sell tickets for a performance at a theater. Here are all the specs. This is an intense program, please follow all instructions carefully. -I am only creating the client program that uses the class and all it's functions -The client program is a menu-driven program that provides the user with box office options for a theater and...
The Course Project can be started in Week 7 and is due by 11:59 pm CT Saturday of Week 8. It must follow standard code formatting and have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does. Pseudocode must be provided in the comment block at the top of the file. This program will allow the...
Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating pattern: A 1 2 3 4 5 6 7 8 9 …… 100 B 1 2 3 4 5 6 7 8 9 …… 100 AISLE C 1 2 3 4 5 6 7 8 9 …… 100 D 1 2 3 4 5 6 7 8 9 …… 100 Either use 2D STL array (array that contains array) or 4 single dimensional STL arrays of size 100. Write a program to display a menu to the user with the options to reserve a seat of choice, reserve a window seat, reserve an aile seat, reserve a seat (any available), withdraw reservation, update reservation (change seat) and display...
For this week's assignment , create and complete a Windows application for the following question. Airline Reservation System: An airline has just bought a computer for its new reservation system. Develop a new system to assign seats on the new airplane( capacity: 10 seats) Display the following alternatives: "Please type 1 for first class, and please type 2 for Economy". If the user enters 1, your application should assign a seat in the first class( seats 1-5). If the user...