airline reservation system-how to creat the 'seat'?

i dont know how to use array boolean to display seat.(the bold paragra

Page 1 of 1

1 Replies - 9122 Views - Last Post: 06 November 2009 - 07:53 AM Rate Topic: -----

#1 lulu0206  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-November 09

airline reservation system-how to creat the 'seat'?

Posted 05 November 2009 - 11:09 PM

A small airline has just purchased a computer for its new automated reservation system. You have been asked to develop a 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, the application should assign a seat in the first-class section (seat 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 one-dimensional arrays of primitive type Boolean to represent the seating chart of the plane. Initialise all the elements in the array to false and 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.

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 three hours”.

import java.util.Scanner;

public class a {
  public static void main(String[] args) {
	Scanner input=new Scanner(System.in);
	
	//Boolean[]r=new Boolean[10];
	int f=0;
	int e=5;
	int exit;
	
	do{
	
	System.out.println();
	System.out.println("~~~~~~~~~~~~~~~~~AIRLINE RESERVATION SYSTEM~~~~~~~~~~~~~~~~~~~");
	System.out.println();
	System.out.println("\t\tPLEASE CHOOSE:");
	System.out.println("\t\t1. FIRST CLASS");
	System.out.println("\t\t2. ECONOMY");
	int section=input.nextInt();
	
	
	switch(section){
		case 1:
			System.out.println();
				System.out.println("YOUR SEATS IS IN THE FIRST CLASS SECTION.");			
				f++;
				if (f<=5){
					
				System.out.println("Your seat number is "+f);
				System.out.println();
				}
				
				else{
					System.out.println();
					System.out.println("The first class section is full.");
					System.out.println("Do you want to be placed at the economy section?(1.yes\t2.no)");
					int full=input.nextInt();
					if (full==1){
					System.out.println("Press 1 to go to the main menu.");
					}
					else{
						System.out.println("next flight leaves in 3 hours.");
					}
				}
				break;
	case 2:
		System.out.println();
			System.out.println("YOUR SEATS IS IN THE ECONOMY SECTION.");			
				e++;
				if ((e>5)&&(e<=10)){
					
				System.out.println("Your seat number is "+e);
				System.out.println();
				}
				
				else{
					System.out.println();
					System.out.println("The economy class section is full.");
					System.out.println("Do you want to be placed at the first class section?(1.yes\t2.no)");
					int full=input.nextInt();
					if (full==1){
					System.out.println("Press 1 to go to the main menu.");
					}
					else{
						System.out.println("next flight leaves in 3 hours.");
					}
				}
				
				
	}
	System.out.println();
	System.out.println("1.main menu\t2.exit");
	exit=input.nextInt();
  }while (exit==1);
  System.out.println();
  System.out.println("~~~~~~~~~~~~~Enjoy your journey!!~~~~~~~~~~~~~~~");
}
}



Is This A Good Question/Topic? 0
  • +

Replies To: airline reservation system-how to creat the 'seat'?

#2 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,619
  • Joined: 15-May 08

Re: airline reservation system-how to creat the 'seat'?

Posted 06 November 2009 - 07:53 AM

create a simple class called seat if you are trying to 'make' a seat.

eg
class Seat
{
     public Seat() {}
     public int seat_number;
     public boolean bIsFirstClass;
}



Then to use it.

Seat ySeat = new Seat();
ySeat.seat_number = 1;
ySeat. bIsFirstClass = true;

// another seat
Seat xSeat = new Seat();
xSeat.seat_number = 6;
xSeat. bIsFirstClass = false;


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1