Airline reservatoin system

I m asked to perform bookin through credit system.i am done with basic things like login,signup ,flight details.but i dont to proceed after this i.e once booking is done by the passenger,his name should go to the flight database...pls help me out guys in preparing the reservation module....here i m posting the code that i ve done so far...


/
import java.io.*;
public class Passenger
{
    // instance variables - replace the example below with your own
    public String Pname;
    public String MailId;
    public String Address;
    public String username;
    public String pwd;

    

    /**
     * Constructor for objects of class Passenger
     */
    public Passenger(String Pname,String MailId,String Address,String username,String pwd)
    {
        // initialise instance variables
        this.Pname = Pname;
        this.MailId = MailId;
        this.Address = Address;
        this.username = username;
        this.pwd = pwd;
       
        
    }
}
    
         
class sample
{
    public static void main(String a[])
    {
        
        Passenger p1 = new Passenger("Vignesh","abcd@yahoo.in","11/5 parthasarathy puram","vicky","xyz123");
        Passenger p2 = new Passenger("Ramesh","efgh@yahoo.in","22/5 parthasarathy puram","rams","fast");
        Passenger p3 = new Passenger("Dinesh","ijkl@yahoo.in","33/5 parthasarathy puram","dinu","pwd12");
        Passenger p4 = new Passenger("Rahul","mnop@yahoo.in","44/5 parthasarathy puram","rahulcool","007bond");
        Passenger p5 = new Passenger("Saravana","ghij@yahoo.in","55/5 parthasarathy puram","sarah","sarav");
        int point=0;
        String usernm[] = {"Vignesh","Rahul","Dinesh","Saravana","Ramesh"};
        int size=usernm.length;
        int points[]={2000,3000,4500,6000,10000};
        int size1=points.length;
        for(int i=0;i<5;i++)
        {
          if(p1.Pname==usernm[i])
          {
            System.out.println("User" + "\t" +usernm[i]+ "\t" +"is having"+"\t" +points[i]); 
          }
        }     
          
        for(int i=0;i<5;i++)
        { 
          if(p2.Pname==usernm[i])
          {
      
             //point =points[i];
             System.out.println("User"+"\t" +usernm[i]+"\t"+ "is having"+"\t" +points[i]); 
         }
        }      
         
         
        for(int i=0;i<5;i++){
          if(p3.Pname==usernm[i])
          {
           
          // point =points[i];
           System.out.println("User"+"\t" +usernm[i]+"\t"+ "is having"+"\t" +points[i]); 
         }
        }
           
  
        for(int i=0;i<5;i++)
        {
          if(p4.Pname==usernm[i])
          {
          
          // point =points[i];
           System.out.println("User"+"\t" +usernm[i]+"\t"+"is having"+"\t" +points[i]); 
          }
        }
          for(int i=0;i<5;i++)
        {
          if(p5.Pname==usernm[i])
          {
          
          // point =points[i];
           System.out.println("User"+"\t" +usernm[i]+"\t"+"is having"+"\t" +points[i]); 
         }
        }
        Flight f =new Flight();
        f.display();
        Booking b = new Booking();
        b.reservation();
        

    }
      
    }


class Flight
{
  int FlightNumber[]={1,2,3,4};
  String Source[]= {"India","China","India","London"};
  String Destination[]= {"U.S","India","U.K","U.S"};
  String DepartureTime[]= {"3.00A.M","11.00P.M","11.30P.M","7.00P.M"};
  String ArrivalTime[]= {"1.00P.M","3.00A.M","2.30A.M","4.00A.M"};
  int Miles[]={8000,9000,8500,10000};
  int Seats[]={15,20,25,20};
  
  void display()
  {
    for(int i=0;i<4;i++)
    {
      System.out.print(""+FlightNumber[i]+"\t"+Source[i]+"\t"+Destination[i]+"\t"+DepartureTime[i]+"\t"+ArrivalTime[i]+"\t"+Miles[i]+"\t"+Seats[i]+"\n");
            
    }
       }
}

  
  
  class Booking extends Flight
  {
    int distance = 0;
    double cost = 0.0;
    int choice;
    Flight f = new Flight();
    
    void reservation()
    {          
    System.out.println("Select your choice");
    System.out.println("1-----> India -U .S");
    System.out.println("2-----> China - India");
    System.out.println("3-----> India - U .K");
    System.out.println("4-----> London - U .S");
   
    try
    {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       int choice = Integer.parseInt(br.readLine());
      switch(choice)
      {
        case 1:
        { 
          for(int i=0;i<4;i++)
          {
          if(f.Source[i]== "India" && f.Destination[i]== "U.S")
          {
            distance = Miles[i];
            cost =(0.1*distance) + distance;
            System.out.println("Trip cost = " + cost);
            System.out.println("Available seats = "+Seats[i]);
            System.out.flush();
            System.out.println("Nmber of seats required:" );
            int sno = Integer.parseInt(br.readLine());
            System.out.println("Available seats:"+(Seats[i] - sno));
                                             
                        
          }
          }
          break;
        }
        
        case 2:
        { 
          for(int i=0;i<4;i++)
          {
          if(f.Source[i]== "China" && f.Destination[i]== "India")
          {
           distance = Miles[i];
           cost =(0.1*distance) + distance;
            System.out.println("Trip cost = " + cost);
            System.out.println("Available seats = "+Seats[i]);
            System.out.flush();
            System.out.println("Nmber of seats required:" );
            int sno = Integer.parseInt(br.readLine());
            System.out.println("Available seats:"+(Seats[i] - sno));
                                             
          }
          }
          break;
        }
    
        case 3:
        { for(int i=0;i<4;i++)
      {
          if(f.Source[i]== "India" && f.Destination[i]== "U.K")
          {
            distance = Miles[i];
            cost =(0.1*distance) + distance;
            System.out.println("Trip cost = " + cost);
           System.out.println("Available seats = "+Seats[i]);
           System.out.flush();
            System.out.println("Nmber of seats required:" );
            int sno = Integer.parseInt(br.readLine());
            System.out.println("Available seats:"+(Seats[i] - sno));
                                             
          }
        } 
        break;
        }
        
        case 4:
        { 
          for(int i=0;i<4;i++)
          {
            if(f.Source[i]== "London" && f.Destination[i]== "U.S")
          {
             distance = Miles[i];
             cost =(0.1*distance) + distance;
            System.out.println("Trip cost = " + cost);
            System.out.println("Available seats = "+Seats[i]);
            System.out.flush();
            System.out.println("Nmber of seats required:" );
            int sno = Integer.parseInt(br.readLine());
            System.out.println("Available seats:"+(Seats[i] - sno));
                                             
          }
        }
          break;
      }
      }}
          
         catch(Exception e)
         {
           
           System.out.println("I/O Error");
         }
    }

  }

Replies

  • jeethu
    jeethu
    Do you have a problem with coding ? or design ? Let us know what design you have in your mind.

You are reading an archived discussion.

Related Posts

IBM is one innovative company that has existed since decades and been a leader in innovation & technology across various sectors. The contest invites innovative ideas and their actual implementation....
CEans, I'm sure we all have different Laptop brands and have used them for at least a few months. Let's share our experiences with the battery lives of the products...
CEans, There's so much happening in the world of engineering and tech that we're always short of people who can bring you all the kick-ass updates. We want to utilize...
I read the below statements(quoted) in some forum and I believe this is true "Ip address(network address) is just use for transfering informatiom from one network to an other.travelling of...
HP’s recently unveiled the reclining touchscreen desktop PC. It’s a TouchSmart edition desktop which means it’s got everything inbuilt and doesn’t even need a keyboard and mouse. On the first...