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



Home Answers Viewqa Java-Beginners reservation of seat in plane
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


liya yusuf
reservation of seat in plane
2 Answer(s)      3 years and 10 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: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());
                }
               }
             }


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
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  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
airline reservation java code - Java Beginners
airline reservation java code   Write a program that simulates... with the following choices: (a) View Seating (b) Book a Seat (c) Cancel a Booking (d) Reset All...; to indicate that a seat is booked and a hyphen ‘-‘ to indicate
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
Draw a Mandelbrot
. A Mandelbrot is a collection of points in the plane whose boundary forms a fractal..., q))   writableRaster.setDataElements(j, k, object...(double p, double q) {   double x = 0.4
Agra Tour Package
Agra Tour Package Better known as the city of Taj; Agra, the former capital of Mughals, is one of the highly visited tourist destinations in India. The city is still ruling the roost in Indian tourism even after it ceases to be seat
Java Arrary - Java Beginners
Java Arrary  Use an array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array
What is CICS?
, colleges and universities, airline reservation systems, insurance companies
java netbean - UML
only plane. Type of travel selection Denoted as Seat numbers assigned First...java netbean   To develop an airline reservation system. The system.... - Assign an appropriate seat. - Display the boarding pass. Outcomes: 1. Apply
Haryana Tourism India
Haryana: A Hub of an Antithetic Tourism Haryana the seat of culture and tradition is considered as one of the greatest tourist spots of India. The amalgamation of the different kinds of tourism like pilgrim tourism, golf tourism
C Programming
C Programming  hi,how can i write a program in C programming to place reservation in air plane from the menu let the user to inter his/her gender(W or M)and draw seats by using ascii codes and choose where he/she will sit
Java to SQL Server Connectivity
_name,cust_nic,cust_contact,cust_address,seat_no,departure_date,amount,total_amount... Seat is Available or Not","Error", JOptionPane.ERROR_MESSAGE ); System.out.println(e.getMessage()); } } Im making a ticket reservation system
railway rsrvation system
railway rsrvation system   Java coding for railway reservation system
Testcases - JUNIT
Testcases   Hi iam doiing project on online reservation i want to know how to write the testcases for this online reservation..........will u help me
test case - JUNIT
test case  Hi i am doing project on online reservation i want to know how to write the test case template for this online reservation
java swings
there is 1 seat available since my system is not standalone so different people will be accessing the software at the same time so at a instant if 1 seat is available and both seat is seen by all the user and if 1 student selects this seat
Array
the following alternatives: Please type 1 for Twin Seat and Please type 2 for Normal Seat. If the user types 1, your application should assign a Twin Seat numbered from 1 to 5. If the user types 2, your application should assign a Normal Seat
project
project  sir i want to a project on railway reservation,sir plz give me the source code   plz give me the source code of railway reservation
ARRAYS - Java Beginners
java.util.regex.*; class Reservation{ private static void writeToFile... name=input.nextLine(); System.out.println("Alloted Seat: "+i); list.add(name
Advertisements
 

 

 

DMCA.com