reservation of seat in plane

reservation of seat in plane

hi,how can i write a program in Java programming to place reservation in air plane from the menu let the user to inter his/her name, age, date of traveling, and the seat in the plane?

View Answers

May 20, 2011 at 1:13 PM

import java.sql.*;
import java.util.*;

class Passenger{
        public int no;
        public String seatA;
        public String seatB;
        public String seatC;
        public String seatD;

        public Passenger() {
        }
        public Passenger(int no, String seatA, String seatB, String seatC,
                        String seatD) {
                this.no = no;
                this.seatA = seatA;
                this.seatB = seatB;
                this.seatC = seatC;
                this.seatD = seatD;
        }
        public int getNo() {
                return no;
        }
        public void setNo(int no) {
                this.no = no;
        }
        public String getSeatA() {
                return seatA;
        }
        public void setSeatA(String seatA) {
                this.seatA = seatA;
        }
        public String getSeatB() {
                return seatB;
        }
        public void setSeatB(String seatB) {
                this.seatB = seatB;
        }
        public String getSeatC() {
                return seatC;
        }
        public void setSeatC(String seatC) {
                this.seatC = seatC;
        }
        public String getSeatD() {
                return seatD;
        }
        public void setSeatD(String seatD) {
                this.seatD = seatD;
        }
}

May 20, 2011 at 1:14 PM

continue..

public class AirlineReservation{
        public static void main(String[] args) throws Exception {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
                Statement st=con.createStatement();
                List<Passenger> list = new ArrayList<Passenger>();
                list.add(new Passenger(1, "A", "B", "C", "D"));
                list.add(new Passenger(2, "A", "B", "C", "D"));
                list.add(new Passenger(3, "A", "B", "C", "D"));
                list.add(new Passenger(4, "A", "B", "C", "D"));
                list.add(new Passenger(5, "A", "B", "C", "D"));
                list.add(new Passenger(6, "A", "B", "C", "D"));
                list.add(new Passenger(7, "A", "B", "C", "D"));
                for(Passenger s : list){
                System.out.println(s.getNo() + "  " + s.getSeatA() + "  " + s.getSeatB() + "  " + s.getSeatC() + "  " + s.getSeatD());
                }
                Scanner input = new Scanner(System.in);
                System.out.println("Enter Name: ");
                String name=input.nextLine();
                System.out.println("Enter Age: ");
                int age=input.nextInt();
                System.out.println("Enter date of travelling(yyyy-MM-dd): ");
                String dt=input.next();
                System.out.println("Enter seat no(like 1 A): ");
                int num = input.nextInt();
                String sn = input.next();
                for(Passenger s : list){
                if(num == s.getNo()){
                if(sn.equals(s.getSeatA())){
                s.setSeatA("X");
                String ss=Integer.toString(num)+sn;
                int i=st.executeUpdate("insert into airlines(name,age,dateOfTravelling,seat) values('"+name+"',"+age+",'"+dt+"','"+ss+"')");
                System.out.println("Seat "+num+""+sn+" is Reserved");                           
                } else if (sn.equals(s.getSeatB())) {
                s.setSeatB("X");
                String ss=Integer.toString(num)+sn;
                int i=st.executeUpdate("insert into airlines(name,age,dateOfTravelling,seat) values('"+name+"',"+age+",'"+dt+"','"+ss+"')");
                System.out.println("Seat "+num+""+sn+" is Reserved");   
                } else if (sn.equals(s.getSeatC())) {
                s.setSeatC("X");
                String ss=Integer.toString(num)+sn;
                int i=st.executeUpdate("insert into airlines(name,age,dateOfTravelling,seat) values('"+name+"',"+age+",'"+dt+"','"+ss+"')");
                System.out.println("Seat "+num+""+sn+" is Reserved");   
                } else if (sn.equals(s.getSeatD())) {
                s.setSeatD("X");
                String ss=Integer.toString(num)+sn;
                int i=st.executeUpdate("insert into airlines(name,age,dateOfTravelling,seat) values('"+name+"',"+age+",'"+dt+"','"+ss+"')");
                System.out.println("Seat "+num+""+sn+" is Reserved");   
                } else {
                System.out.println("Not Available");
                }
                }
                System.out.println(s.getNo()+"  "+s.getSeatA()+"  "
                +s.getSeatB()+ "  "+s.getSeatC()+"  "+ s.getSeatD());
                }
               }
             }

Ads









Related Tutorials/Questions & Answers:
reservation of seat in plane
reservation of seat in plane  hi,how can i write a program in Java programming to place reservation in air plane from the menu let the user to inter his/her name, age, date of traveling, and the seat in the plane
place reservation in plane
place reservation in plane   hi,how can i write a program in Java programming to place reservation in air plane from the menu let the user to inter his/her name, age, date of traveling, and the seat in the plane
Advertisements
Railway reservation
reservation process. Customer should be able to check the availability... of ticket to intermediate stations. Customer should also be able to check the seat availability in a train. If seat is available, customer should be able to reserve
ModuleNotFoundError: No module named 'seat'
ModuleNotFoundError: No module named 'seat'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'seat' How to remove the ModuleNotFoundError: No module named 'seat' error
ModuleNotFoundError: No module named 'seat'
ModuleNotFoundError: No module named 'seat'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'seat' How to remove the ModuleNotFoundError: No module named 'seat' error
ModuleNotFoundError: No module named 'plane'
ModuleNotFoundError: No module named 'plane'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'plane' How to remove the ModuleNotFoundError: No module named 'plane'
ModuleNotFoundError: No module named 'plane-a'
ModuleNotFoundError: No module named 'plane-a'  Hi, My Python... 'plane-a' How to remove the ModuleNotFoundError: No module named 'plane... to install padas library. You can install plane-a python with following command
coding for online reservation
coding for online reservation  coding for online reservation
railway reservation
railway reservation  hello sir, i am creating railway reservation... = new JLabel(ddd); lbl4 = new JLabel("Reservation System"); btnRes = new JButton("Reservation"); btnEnq = new JButton("Enquiry"); btnCont
railway reservation
railway reservation  hello sir, i am creating railway reservation... = new JLabel(ddd); lbl4 = new JLabel("Reservation System"); btnRes = new JButton("Reservation"); btnEnq = new JButton("Enquiry"); btnCont
online bus reservation
online bus reservation   online bus reservation using jsp coding
coding for railway reservation project
coding for railway reservation project  i want to help for creating coding in visual basic for railway reservation project
Railway Reservation
Railway Reservation  i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design the frame... aftr clickg run i need to enter data to ma frame and the data
ModuleNotFoundError: No module named 'fight-plane'
ModuleNotFoundError: No module named 'fight-plane'  Hi, My Python... 'fight-plane' How to remove the ModuleNotFoundError: No module named 'fight-plane' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ljy-plane'
ModuleNotFoundError: No module named 'ljy-plane'  Hi, My Python... 'ljy-plane' How to remove the ModuleNotFoundError: No module named 'ljy-plane' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'ming-plane'
ModuleNotFoundError: No module named 'ming-plane'  Hi, My Python... 'ming-plane' How to remove the ModuleNotFoundError: No module named 'ming-plane' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'plane-feiji'
ModuleNotFoundError: No module named 'plane-feiji'  Hi, My Python... 'plane-feiji' How to remove the ModuleNotFoundError: No module named 'plane-feiji' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'plane-fight'
ModuleNotFoundError: No module named 'plane-fight'  Hi, My Python... 'plane-fight' How to remove the ModuleNotFoundError: No module named 'plane-fight' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'plane-frighting'
ModuleNotFoundError: No module named 'plane-frighting'  Hi, My... named 'plane-frighting' How to remove the ModuleNotFoundError: No module named 'plane-frighting' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'plane-fx'
ModuleNotFoundError: No module named 'plane-fx'  Hi, My Python... 'plane-fx' How to remove the ModuleNotFoundError: No module named 'plane-fx... to install padas library. You can install plane-fx python with following
ModuleNotFoundError: No module named 'plane-fxx'
ModuleNotFoundError: No module named 'plane-fxx'  Hi, My Python... 'plane-fxx' How to remove the ModuleNotFoundError: No module named 'plane... have to install padas library. You can install plane-fxx python with following
ModuleNotFoundError: No module named 'plane-war'
ModuleNotFoundError: No module named 'plane-war'  Hi, My Python... 'plane-war' How to remove the ModuleNotFoundError: No module named 'plane... have to install padas library. You can install plane-war python with following
ModuleNotFoundError: No module named 'snakes-on-a-plane'
ModuleNotFoundError: No module named 'snakes-on-a-plane'  Hi, My... named 'snakes-on-a-plane' How to remove the ModuleNotFoundError: No module named 'snakes-on-a-plane' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-reservation'
ModuleNotFoundError: No module named 'django-reservation'  Hi, My... named 'django-reservation' How to remove the ModuleNotFoundError: No module named 'django-reservation' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-reservation'
ModuleNotFoundError: No module named 'django-reservation'  Hi, My... named 'django-reservation' How to remove the ModuleNotFoundError: No module named 'django-reservation' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'redis_reservation'
ModuleNotFoundError: No module named 'redis_reservation'  Hi, My... named 'redis_reservation' How to remove the ModuleNotFoundError: No module named 'redis_reservation' error? Thanks   Hi, In your
Plotting equations on a cartesian Plane
Plotting equations on a cartesian Plane  Hey, Im sort of a beginner of java, and i at the moment of working on a program that takes the input of an equation (eg. y=3x) and plots possible values for it on a cartesian plane thats
ModuleNotFoundError: No module named 'damo-Plane-Wars'
ModuleNotFoundError: No module named 'damo-Plane-Wars'  Hi, My... named 'damo-Plane-Wars' How to remove the ModuleNotFoundError: No module named 'damo-Plane-Wars' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'damo-Plane-Wars'
ModuleNotFoundError: No module named 'damo-Plane-Wars'  Hi, My... named 'damo-Plane-Wars' How to remove the ModuleNotFoundError: No module named 'damo-Plane-Wars' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'damo-Plane-Wars'
ModuleNotFoundError: No module named 'damo-Plane-Wars'  Hi, My... named 'damo-Plane-Wars' How to remove the ModuleNotFoundError: No module named 'damo-Plane-Wars' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'envoy-data-plane'
ModuleNotFoundError: No module named 'envoy-data-plane'  Hi, My... named 'envoy-data-plane' How to remove the ModuleNotFoundError: No module named 'envoy-data-plane' error? Thanks   Hi, In your

Ads