Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a Java Expert!

Join 300,509 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,908 people online right now. Registration is fast and FREE... Join Now!




Airplane Reservation System

 

Airplane Reservation System, !!!

seoxheesu

14 Feb, 2008 - 04:52 PM
Post #1

New D.I.C Head
*

Joined: 14 Feb, 2008
Posts: 2



Thanked: 1 times
My Contributions
Airline Reservations System
A small airline has just purchased a computer for its new automated reservation system.
You have been asked to develop the new system called ARSystem. You are to write an
application to assign seats on each flight of the airline's only plane (capacity: 24 seats.)
Your application should display the following alternatives: Please type 1 for FirstClass
and Please type 2 for Economy. If the user types 1, your application should assign a seat
in the first-class section (seats 1-8). If the user types 2, your application should assign
a seat in the economy section (seats 9-24). 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."
** Comment too , l2format **
(Create additional classes as necessary for it to work as intended)
You will recieve a Standard Grade for completion of this.
Extra credit will be given for a more creative approach to the problem, either minimum amount
of code, an additional display of seating beyond just the boarding pass, etc...










so far i did

CODE

public class Reservation{

    int i=0;
    int size = 24;
    boolean[]seats=new boolean[24]

    private void Reservation(){
    emptyPlane();
    fullPlane();
    firstFull();
    economyFull();
    randomPlane();
    }

    private void emptyPlane (int i){
       for (i=0; i<size; i++)
           seats = false;
    }
    private void fullPlane (int i){
       for (i=0; i<size; i++)
           seats = true;
    }
    private void randomPlane (int i){
       for (i=0; i<size; i++)
           seats = false;
    }
    private void firstFull (int i){
       for (i=0; i<size; i++)
           seats = false;
    }
   private void economyFull(int i){
       for (i=0; i<size; i++)
           seats = true;
    }

*edit: Please use code tags in the future, thanks! code.gif

This post has been edited by Martyr2: 14 Feb, 2008 - 09:53 PM

User is offlineProfile CardPM
+Quote Post


Martyr2

RE: Airplane Reservation System

14 Feb, 2008 - 09:56 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 7,246



Thanked: 820 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
If you do a search on this board you will find this exact assignment being covered on other threads. Many of them can give you some points of direction. One being...

Airplane Seat Reserveration System Thread

While it and many like it are covered in other languages like C++, you can certainly see what is going on because Java is similar syntax. Plus we speak English too. wink2.gif

Also it would be advisable that you tell us the exact problem you are having with your code. We are genius', not mind readers. Thanks! smile.gif
User is offlineProfile CardPM
+Quote Post

seoxheesu

RE: Airplane Reservation System

16 Feb, 2008 - 12:48 PM
Post #3

New D.I.C Head
*

Joined: 14 Feb, 2008
Posts: 2



Thanked: 1 times
My Contributions
This is what I did so far. But I do not know what to do after this. Please help me.




CODE

/* Program: ARSystem
* Description:
*
* Name: Rachel
* Date: 2/8/08
* Period: 3
*/

import java.util.Scanner;
import java.util.Random;
public class ARSystem {
  
    public static void main(String[] args) {
    
      Scanner sc = new Scanner(System.in);
      int x,y;
      boolean[]seats= new boolean [24];
    

        
      System.out.println ("************************************************");
      System.out.println ("|             Welcome to Rachel's              |");
      System.out.println ("|          Airline Reservation System          |");
      System.out.println ("************************************************");
    
      
      System.out.println ("Please type 1 for First Class or 2 for Economy");
      x=sc.nextInt();
  
        
      //If user inputs in 1, assign a seat in the first-class section (seats 1-8).
      // If the user types 2, assign a seat in the economy section (seats 9-24).
      if (x==1){
        Random generator = new Random();
        x = generator.nextInt(8) + 1;
      }
      if (x==2){
        //Math.random();
       }
    
      //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.
      
      System.out.println ("Which would you like?");
      System.out.println ("1)Boarding Pass");
      System.out.println ("2)Seating Chart");
      y=sc.nextInt();
    
      if (y==1){
        System.out.println ("--------------------------------------");
        System.out.println ("       Your Seat Number is: " + x);
        System.out.println ("--------------------------------------");
      }
    }
}
















new class

public class Reservation
{
  int i=0;
  int size = 24;
  boolean[]seats= new boolean [size];
  
    public Reservation()
    {
      emptyPlane();
      fullPlane();
      firstFull();
      economyFull();
      randomPlane();
    }
  
    public void emptyPlane()
    {
      for (int i=0; i<size; i++)
        seats[i]=false;
    }
    public void fullPlane()
    {
      for (int i=0; i<size; i++)
        seats[i]=true;
    }
    public void firstFull()
    {
      for (int i=0; i<9; i++)
        seats[i]=true;
    }
    public void economyFull()
    {
      for (int i=0; 8<i<24; i++)
        seats[i]=true;
    }
    public void randomPlane()
    {
      for (int i=0; i<size; i++)
        seats[i]=false;
    }
    public void printPlane()
    {
      for (int i=0; i<size; i++)
        System.out.println("");
    }
}




This post has been edited by seoxheesu: 16 Feb, 2008 - 02:31 PM
User is offlineProfile CardPM
+Quote Post

gyron

RE: Airplane Reservation System

19 Feb, 2008 - 08:49 AM
Post #4

D.I.C Head
**

Joined: 9 Jan, 2007
Posts: 61


My Contributions
What is it that you are stuck at? In other words, what's the next thing that needs to be done that you unfortunately cant do? Supply some details and we would be glad to help.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 05:09AM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month