Question

Write pseudocode for a program where the seating map for a particular performance at a theater...

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 enters a valid row and seat number, the program determines if that seat is available, and if so, marks it as reserved with an “X” (available seats are not marked in any way).

b) Once the user quits, the program outputs

i) each row number followed by the seat numbers in that row that have been reserved

ii) the total number of reserved seats

iii) the total number of available seats This seating map applies only to this particular show. For other shows, the seating map may contain a different number of rows and seats per row, and the program must be capable of being modified for those by editing only two lines of code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* The JAVA program to enter the size of each household and enter row and seat number continously to reserve the seat
and on quit, display the reserved seats , number of seats reserved, number of seat available */
import java.util.Scanner;
class seatmap
{
public static void main(String arg[])
   {
       int rowsize=70;
       int colsize=100;
       int row,col,size,avail,reserved;
       char seat[][]=new char[rowsize][colsize];
       int i,j;
       Scanner in=new Scanner(System.in);
       // initialaize all seats to blank
       for(i=0;i<rowsize;i++)
           {
               seat[i]=new char[colsize];
               for( j=0;j<colsize;j++)
                   seat[i][j]=' ';
               }

   // loop continiously untill 0 is pressed
       while(true)
           {
               System.out.print("Enter the household size (0 to quit) : ");
               size=in.nextInt();
               if(size==0)
                   break;
               for(i=1;i<=size;i++)
                   {
                   System.out.print("\nEnter the row numer(0 to 69) and a seat number(0 to99) : ");
                   row=in.nextInt();
                   col=in.nextInt();
                   // if desires row and seat is not available
                   if   (seat[row][col]=='X')
                           {
                           System.out.print("\nSeat is not available. try again ..");
                           i--;
                           }
                           else
                               {
                                   seat[row][col]='X'; // reserve the seat

                               }
                           }
               }

           System.out.println("Reserved Seats below");
           reserved=0;
           // print reserved seat by row number and seat number
           for(i=0;i<rowsize;i++)
               {
                   for(j=0;j<colsize;j++)
                       {
                           if(seat[i][j]=='X')
                               {
                               System.out.println("Row : "+i + " seat: "+ j) ;
                               reserved+=1;
                               }
                       }
           }
           //show number of reserved seats
           System.out.println("Total Number of seat reserved : " +reserved);
           // calculate and show number of available seats
           avail=(rowsize*colsize)-reserved;
           System.out.println("Total Number of seat available : " +avail);

}
}

//sample run

Add a comment
Know the answer?
Add Answer to:
Write pseudocode for a program where the seating map for a particular performance at a theater...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:...

    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...

  • Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your...

    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...

  • For c++ Write a program that can be used to assign seats for a commercial airplane....

    For c++ Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 rows through 13 are economy class. Your program must prompt the user to enter the following information: Ticket type (first class, business class, or economy class) Desired seat a. b. Output the seating plan in the...

  • Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating...

    Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 1 2 3 21 22 23 24 25 Implement a well-structured Java program to enable a user to make and cancel seat reservations for the bus. The program uses Array to store the reservation information: 0...

  • A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is...

    A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Implement a well-structured C program to enable a user to make and cancel seat reservations for the bus. The program uses a text-file seats.txt to store the reservation...

  • Java program for an Airplane Seating Reservation.

    Need help with this, please!Write a java program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class, rows3 to 7 are business class, and rows 8 to 13 are economy class. Your program prompts the user to enter the following information:- Ticket type (first class or economy class)- For economy class, the smoking or non-smoking section- Desired seatOutput the seating...

  • The Course Project can be started in Week 7 and is due by 11:59 pm CT...

    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...

  • Can you help us!! Thank you! C++ Write a program that can be used by a...

    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...

  • In C++. Write a program that can be used to assign seats for a commercial airplane...

    In C++. Write a program that can be used to assign seats for a commercial airplane and print out the ticket total. The airplane has 13 rows, with row 7 being the Emergency Exit row. Each row has 7 seats, there are two seats on each side of the plane and three seats in the middle with aisles on both sides. Rows 1 and 2 are considered first class with tickets for this specific  flight being $872.00 round trip. Rows 3...

  • I have to write a C program to assign seats on each flight of the airline’s...

    I have to write a C program to assign seats on each flight of the airline’s only plane (capacity: 40 seats, in 10 rows). For the sake of simplicity, assume that each row has 4 seats labeled A, B, C, D. Your program should display the following menu of alternatives: Please type 1 for "first class" Please type 2 for "business class" Please type 3 for “economy class”. If the person types 1, then your program should assign a seat...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT