1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
timurjin [86]
4 years ago
10

A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new

system. You are to write an application to assign seats on each flight of the airline’s only plane (capacity: 10 seats).
Your application should display the following alternatives: Please type 1 for First Class and Please type 2 for Economy.
If the user types 1, your application should assign a seat in the firstclass section (seats 1–5).
If the user types 2, your application should assign a seat in the economy section (seats 6–10).
Your application should then display a boarding pass indicating the person’s seat number and whether it is in the first-class or economy section of the plane.
Use a one-dimensional array of primitive type boolean to represent the seating chart of the plane. Initialize all the elements of the array to false to indicate that all the seats are empty. As each seat is assigned, set the corresponding elements of the array to true to indicate that the seat is no longer available.
Your application should never assign a seat that has already been assigned. When the economy section is full, your application should ask the person if it is acceptable to be placed in the first-class section (and vice versa). If yes, make the appropriate seat assignment. If no, display the message "Next flight leaves in 3 hours."

Computers and Technology
1 answer:
musickatia [10]4 years ago
3 0

Answer:

Here is the simple JAVA program.

import java.util.Scanner;   // to take input from user

public class AirlineReservationSystem {  //airline reservation class

 public static void main(String[] args) {  //start of main() function body

Scanner input=new Scanner(System.in);   //Scanner class instance

int first_class=0;  //stores the first class seat numbers

int eco_class=5; //holds the economy class seat numbers

int quit;  //used to quit the reservation system  

System.out.println("Welcome to the AIRLINE RESERVATION SYSTEM!");  // displays welcome message

do{   //start of do while loop  

//displays following messages for user to make choice between 2 sections

System.out.println("Please type 1 for First Class ");

System.out.println("Please type 2 for Economy ");

int choice=input.nextInt();  //takes the choice from user

switch(choice){ // takes choice of user from first class or economy section

 case 1:  //when user enters first class as choice

   first_class++;  

//increments count of first class by 1 every time user reserves a seat in first //class

if (first_class<=5){  // the seats in first class section should be between 1-5

//displays message of seat reserved in first class

  System.out.println("Your seat is assigned in First Class.");    

System.out.println("Your seat number is "+first_class);  

//assigns seat number in first class    }      

   else{

// displays following message when number of seats in first class exceed 5

System.out.println("No seat is available in First Class");

//asks user if he wants to placed in economy class when there is no seat //available in first class

System.out.println("Do you want to be placed at the Economy section?(1.yes\t2.no)");

  int full=input.nextInt();  //reads yes or no (1 or 2) from user

    if (full==1){  //if user entered 1

  System.out.println("Enter 1 to return to main menu to reserve a seat in Economy class.");

    }  // asks user to press 1 to go to main menu

    else{  //displays following message if user enters 2

  System.out.println("Next flight leaves in 3 hours.");}   }

   break;

case 2:  //when the user choose to reserve seat in economy class

                        eco_class++;  

//increments count of first class by 1 every time user reserves a seat in //economy class

//the seats of economy class ranges from 6 to 10  

if ((eco_class>5)&&(eco_class<=10)){  

//display message about economy class seat reservation

System.out.println("Your seat is assigned in Economy Class.");

//assigns seat number in economy class    

  System.out.println("Your seat number is "+eco_class);  }  

   else{

// displays following message when number of seats in economy class //exceed 10

System.out.println("No seat is available in Economy Class");

//asks user if he wants to placed in first class when there is no seat //available in economy class

System.out.println("Do you want to be placed at the First class section?(1.yes\t2.no)");  

  int full=input.nextInt(); //reads yes or no (1 or 2) from user

    if (full==1){ //if user entered 1

  System.out.println("Enter 1 to return to main menu to reserve a seat in business class.");  

// asks user to press 1 to go to main menu }

    else{  //displays following message if user enters 2

  System.out.println("Next flight leaves in 3 hours."); }} }

System.out.println("1.main menu\t2.quit");  

quit=input.nextInt();

//if user presses 2 it reads that value from user and store it in quit variable

 }while (quit==1);  //the loop stops when user chooses quit

 System.out.println("Bye! Have a nice day!"); }  }  

//displays message when user quits the reservation system

Explanation:

The program is well explained in the comments mentioned with each line of the program. The program uses switch statement for the user to make choice between first and economy class. If the user selects first class, then his seat is reserved in first class and a seat number is generated to user. The range of first class seats is from 1 to 5. When this range is exceeded the  person is asked if he wants to be placed in economy class. If the user presses one then the person is asked to go back to main menu and reserve seat in economy class. If user enters 2 then the system exits. Same flow goes with the economy class seat reservation. The do while loop keeps executing until the user quits the system. If the user presses 2 to quit, the system exits after displaying bye message.

You might be interested in
The component of an information system consisting of raw facts is the definition for which of the following?
julsineya [31]

Answer:

The answer to this question is: Information

An information system is a set of command that i used to analyze available information in order to create a better decision for the company.

Which means that information will not be able to do any function of it does not possess the initial information, to begin with, so we can conclude that information is a major component of the information systems. hope this makes sense in your mind lol

Explanation:

4 0
3 years ago
Read 2 more answers
How has the Internet expanded the reach of all of these types of media?
iragen [17]

the Internet made it easier for us to find information or to communicate with one another.

5 0
3 years ago
A student sits down at a computer and presses the power button. the computer does not turn on. what is a logical explanation as
ASHA 777 [7]
Since the computer is not working, it is best for the student to test methods that will ensure that there may be complications as to why it is not turning on and why it still off. The most basic step in determining the reason is whether the computer's plug is plugged in the outlet and the student should ensure whether it is plug or unplug.
4 0
3 years ago
Which block in this module represents the variable?
sasho [114]

Explanation:

jdbfifnmathljnfeijrjdjej.http.com

6 0
3 years ago
What is the extension of a BASIC256 program file?​
algol13

Answer:

The extension of a BASIC-256 program file is kbs

4 0
3 years ago
Other questions:
  • What protocol must be supported by routers in order to utilize remote assistance easy connect?
    10·1 answer
  • Required
    12·1 answer
  • Google Ads was designed to help businesses achieve online success. To accomplish this, Google Ads was built on three core princi
    13·1 answer
  • What is the output of executing the code segment?
    7·1 answer
  • Whay device is recommended to use to install windows 10
    13·1 answer
  • What's ur favorite color and your dream car
    8·2 answers
  • 1. what is another name for CPU?
    6·1 answer
  • Write a function that takes a list and returns its first element​
    15·1 answer
  • A(n) ________ is a wonder of miniaturization combining a CPU, GPU, and sundry other support logic onto a single silicon die, sav
    9·1 answer
  • Global communication and transportation technologies are an example of a(n) ____
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!