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?

View Answers

May 20, 2011 at 1:12 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:13 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());
                }
               }
             }









Related Tutorials/Questions & Answers:
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
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
Advertisements
airline reservation - Java Beginners
airline reservation example  (Airline Reservation System) A small.... You have... seats on each flight of the airlines? only plane (capacity: 10 seats). Please give an example of reservation
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
Railway reservation
Railway reservation  Railway Department wants to automate the ticket reservation process. Customer should be able to check the availability of a train by giving the source and destination. Assume that there is no booking
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
coding for online reservation
coding for online reservation  coding for online reservation
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 '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 '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
reservation system - Java Beginners
reservation system  hi help me write a program on a railway reservation system that records the destination of the passengers.It should be decided by the date on which they are to arrive on their destinations and also the number
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 '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
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
railway reservation system - Java Beginners
railway reservation system  help me develop a code on a railway reservation system which maintains records of passengers traveling in the different..., the reservation of the passengers is made by supplying the train number or the the name
ModuleNotFoundError: No module named 'lss-plane-war'
ModuleNotFoundError: No module named 'lss-plane-war'  Hi, My... 'lss-plane-war' How to remove the ModuleNotFoundError: No module named 'lss-plane-war' 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 'lss-plane-war'
ModuleNotFoundError: No module named 'lss-plane-war'  Hi, My... 'lss-plane-war' How to remove the ModuleNotFoundError: No module named 'lss-plane-war' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'reaction-plane-fit'
ModuleNotFoundError: No module named 'reaction-plane-fit'  Hi, My... named 'reaction-plane-fit' How to remove the ModuleNotFoundError: No module named 'reaction-plane-fit' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'snmpsim-control-plane'
ModuleNotFoundError: No module named 'snmpsim-control-plane'  Hi...: No module named 'snmpsim-control-plane' How to remove the ModuleNotFoundError: No module named 'snmpsim-control-plane' error? Thanks   Hi
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
ModuleNotFoundError: No module named 'odoo10-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo10-addon-hotel-reservation' ...: No module named 'odoo10-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-reservation'
ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-reservation...: ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-reservation' How...-reservation' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-reservation'
ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-reservation...: ModuleNotFoundError: No module named 'odoo10-addon-report-hotel-reservation' How...-reservation' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo11-addon-hotel-reservation' ...: No module named 'odoo11-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo11-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo11-addon-hotel-reservation' ...: No module named 'odoo11-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation'
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation...: ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation' How...-reservation' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation'
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation...: ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation' How...-reservation' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation'
ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation...: ModuleNotFoundError: No module named 'odoo11-addon-report-hotel-reservation' How...-reservation' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' ...: No module named 'odoo12-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' ...: No module named 'odoo12-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' ...: No module named 'odoo12-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' ...: No module named 'odoo12-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation'
ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' ...: No module named 'odoo12-addon-hotel-reservation' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hotel-reservation' error
ModuleNotFoundError: No module named 'place'
ModuleNotFoundError: No module named 'place'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'place' How to remove the ModuleNotFoundError: No module named 'place'

Ads