Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners place reservation in plane
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


liya yusuf
place reservation in plane
2 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


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?


Advertisement
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
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
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
coding for railway reservation project
coding for railway reservation project  i want to help for creating coding in visual basic for railway reservation project
online bus reservation
online bus reservation   online bus reservation using jsp coding
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
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
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
to use ArrayList in the place of Vector
to use ArrayList in the place of Vector  public Enumeration getInterfaces() { ISCMetaType currentType = this; ArrayList allInterfaces = new ArrayList(); while( currentType != null
to use ArrayList in the place of Vector
to use ArrayList in the place of Vector  public Enumeration getInterfaces() { ISCMetaType currentType = this; ArrayList allInterfaces = new ArrayList(); while( currentType != null
JavaScript where to place in HTML
JavaScript where to place in HTML   Where to place JavaScript code into HTML Code?   Placing JavaScript code into HTML Code In HTML, JavaScript can be declared anywhere either in <Head>? or <Body>? Tag
how to prepare railway reservation form using core java concepts
how to prepare railway reservation form using core java concepts  write code for online railway reservation form: The following constraints are: a) Fix the no.of Tickets alloted for online reservation b) on each ticket booking
airline reservation java code - Java Beginners
airline reservation java code   Write a program that simulates the booking of seats on board a small airplane. The layout of the aircraft is illustrated below. You will be required to create a menu based system
Inserting id in place of name to database
Inserting id in place of name to database  Hello, I have a database department where I have "id" and "name". I am fetching this data to a jsp form... this form to another table and in place of "name" of department I wanted to insert
Place array of bytes in buffer
Place array of bytes in buffer In this tutorial you will see how to place array of bytes in buffer. The put method of CharBuffer class transfers the entire content of the given source character array into a buffer. Code
Place array of double in a buffer
Place array of double in a buffer In this tutorial you will see how to place array of double in buffer. The put method of DoubleBuffer class transfers the entire content of the given source double array into a buffer. Code
class NSCFString autoreleased with no pool in place - just leaking
class NSCFString autoreleased with no pool in place - just leaking  Hi, In my application following error is coming: class NSCFString autoreleased with no pool in place - just leaking What is the solution? Thanks
About Nehru Place Market Delhi
Nehru Place of New Delhi Nehru Place is one of the newer markets in New Delhi... Place. Nehru Place was built in the southern part of the state of Delhi... been around when Nehru Place first opened. Some concerns have come about over how
How to use place hoder in IE(version : 8)
How to use place hoder in IE(version : 8)  how to use placeholder for input field(type=text) and password field (type= password) in IE
where to place persistence.xml in Maven 3 project
where to place persistence.xml in Maven 3 project  Hi, The persistence xml should be places in the meta inf folder in maven based project. But I...; Hi, You should place this in src\main\resources\META-INF folder. Read
where to place persistence.xml in Maven 3 project
where to place persistence.xml in Maven 3 project  Hi, The persistence xml should be places in the meta inf folder in maven based project. But I...; Hi, You should place this in src\main\resources\META-INF folder. Read
hw to use a place holder - JSP-Servlet
hw to use a place holder  Dear sir, Thanks for sending a code now i... that excel sheet i.e this matter will take a (correct place holder)parameter values... take the (correct place holder)parameter values from the excel file so please
continue of doubts in place ad - JSP-Servlet
continue of doubts in place ad  and when user clicks on confirm check box then only save or submit button should get displayed and when clicked on save everyting selected on place ad page should get saved in database .and when
Information about Connaught Place Delhi
Connaught Place of Delhi The Connaught Place is a valuable commercial centre in Delhi. This is a massive shopping centre in Connaught Place Delhi.... The Connaught Place was first built in the middle of Delhi in 1931. Its construction
how to reverse a string without changing its place
how to reverse a string without changing its place  how to reverse a string without changing its place   Hi Friend, Another way of reversing string: import java.util.*; public class ReverseString{ public static
 

 

 

DMCA.com