Java code
import java.util.*;
class solution
{
public static void main(String args[])
{
// create an array with size 28 to
store bus seats status
int seats[] = new int[28];
int i=0;
// initialize all 28 elements of
array with 0
while(i<28)
{
seats[i] =
0;
i+=1;
}
// declare a variable to store
available seats
int seats_count = 28;
// create object for scanner
class
Scanner scan = new
Scanner(System.in);
// iterate while loop until user
chooses exit option
while(true)
{
// print
menu
System.out.println("1.Display number of available seats.\n2.Display
seat status for all seats.\n3.Reserve seat(s).\n4.Delete
reservation(s).\n5.Exit\n");
// ask user
to chose an option
System.out.print("Please select your choice[1, 2, 3, 4 or 5]:
");
// read users
option
int option =
scan.nextInt();
// if user
option is 1
if(option ==
1)
{
// count available seats
int count = 0;
for(i=0;i<28;i++)
if(seats[i] == 0)
count++;
// print available seats
System.out.println("\nNumber of available seats
= "+count);
}
// if user
option is 2
else if(option
== 2)
{
// call displaySeats() method by passing seats
array
displaySeats(seats);
}
// if user
option is 3
else if(option
== 3)
{
// call displaySeats() method by passing seats
array
displaySeats(seats);
// display available seats
System.out.print("\nThere are "+seats_count+"
seats available. Please enter required number of seats: ");
// read number of required seats to
reserve
int r_seats = scan.nextInt();
// check for available seats
if(r_seats > seats_count)
{
// print insufficient
available seats
System.out.println("\nError:
Insufficient available seats.");
}
// check for required seats number
validity
else if(r_seats <= 0)
{
// print invalid number of
seats
System.out.println("\nError:
Invalid number of seats.");
}
else
{
// read each and every seat
number and check if it is reserved
int flag = 0;
for(i=0;i<r_seats;i++)
{
System.out.print("Enter seat number to reserve: ");
int seat =
scan.nextInt();
if(seats[seat-1] == 1)
{
flag = 1;
break;
}
else
{
seats[seat-1] = 1;
seats_count--;
}
}
// if any one of the seats is
already empty, print error message
if(flag == 1)
{
System.out.println("Error: one or more required seats already
reserved.");
}
else
{ // print
success message
System.out.println("Required seats are successfully
reserved.");
}
}
}
// if user
option is 4
else if(option
== 4)
{
// call displaySeats() method by passing seats
array
displaySeats(seats);
System.out.print("\n Please enter required
number of seats to be deleted: ");
// read number of required seats to delete
int r_seats = scan.nextInt();
// check for seats numbers validity
if(r_seats > seats_count || r_seats <=
0)
{
System.out.println("\nError:
Invalid number of reservations to delete.");
}
else
{
// read each and every seat
number and check if it is reserved
int flag = 0;
for(i=0;i<r_seats;i++)
{
System.out.print("Enter seat number of reservation to be deleted:
");
int seat =
scan.nextInt();
if(seats[seat-1] != 1)
{
flag = 1;
break;
}
else
{
seats[seat-1] = 0;
seats_count++;
}
}
// if any one of the seats is
already empty, print error message
if(flag == 1)
{
System.out.println("Error: one or more required seats already
empty.");
}
else
{ // print
success message
System.out.println("Required reservations successfully
deleted.");
}
}
}
else if(option
== 5)
{
// stop the program
break;
}
else
{
System.out.println("\nPlease chose a valid
option");
}
// ask user to
press enter key
System.out.print("\nPress Enter key to continue . . .");
String c =
scan.nextLine();
c =
scan.nextLine();
System.out.println("");
}
}
public static void displaySeats(int seats[])
{
// visit each seat in the seats
array
System.out.println("");
for(int i=0;i<7;i++)
{
for(int
j=1;j<=4;j++)
{
if(seats[i*4+j-1] == 0)
// print seat number
System.out.print("[\t"+((i*4)+j)+"\t] ");
else
// print reserved
System.out.print("\tReserved
");
}
System.out.println("");
}
}
}
Sample Input/Output




Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating...
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...
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...
C++ Help please- kind of long. The aim is to implement a seat reservation system for a passenger airplane. We assume a small airplane with 10 rows and 4 seats per row. We assume that the seat chart is initially stored in a file “chartIn.txt” in the following format: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 ...
MAKE SURE YOU TEST THE PROGRAM FISRT. DON'T PUT THE CODE WITHOUT TESTING. MAKE SURE ALL THE STEPS ARE FOLLOWED IN CORRECT MANNER ONLY USE VISUAL STUDIO C# CONSOLE APPLICATION Use File IO (NO JAVA CODING) Create a C# Console program that will demonstrate the use of File IO, Arrays, and Classes. This assignment has a number of requirements. Carefully read the document and note all the requirements. Also keep in mind that many of the requirements for this assignment...
This program is in C++ which reserves flight seats. It uses a file imported to get the seat chart called "chartIn.txt" which looks like this 1 A B C D E F 2 A B C D E F It continues until row 10. Sorry unable to provide the chartIn.txt file. I am having issues with function displaySeats, it displays then but when it comes to 10 the row looks like this 1 0 A B C D E ,...
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...
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...
Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...
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...
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...