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



Home Answers Viewqa Java-Beginners reservation of seat in plane

Have Programming Question? Ask it here!
 
 
 


liya yusuf
reservation of seat in plane
2 Answer(s)      2 years and 11 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
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
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
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
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
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
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
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
ARRAYS - Java Beginners
java.util.regex.*; class Reservation{ private static void writeToFile... name=input.nextLine(); System.out.println("Alloted Seat: "+i); list.add(name
java - Java Beginners
java  how to get the details railway reservation details and passengers reserved for a particular train using java
Servlets - JSP-Servlet
Servlets  i have to create a database in SQL server 2005 on railway reservation system.please help me do
jsp coding
jsp coding  what is the simple jsp code for bus ticket reservation system
JSP
JSP  Create a JSP to check the status of bus ticket reservation from the database. Status will be marked with character. Reserved (r), waiting (w... Reservation
jsp code - JSP-Servlet
jsp code  sample code to create hyperlink within hyperlink example: reservation: train: A/C department non A/c Department
java + grid - Java3D
java + grid  i need to give the output of the application in the form of a grid in XY-plane,the grid should have different colors for regions of different value range
how can retrieve more than one values in text field using ajax?
using php and ajax. Problem is that i want to search seat numbers bases of batch... first then in mysql db retrieve seat numbers 1,2,3,4 in text boxes problem...($result)) { echo "<input name='seat' type='text' value=".$row['Seat_Number
java program
java program  write a program showing two threads working simultanously upon two objects(in theater one object "cut the ticket" andsecond object "show is the seat
Used Handicap Vans
Used Handicap Vans  *** Deleted by admin **** Used Handicap Vans Offers adaptive equipment including handicap accessible vans, scooter lifts, swivel car seat, wheelchair carriers and wheelchair vehicles
Assign Airline Seats to Passengers using Java
. For this purpose, we have created setter and getter methods and stored the some seat numbers into the ArrayList. Then we have allowed the user to enter seat of their choice to reserve. If the seat is available, your seat will get reserved
java program
java program  hello.. do u all have any source to do the java programming for Snake and Ladder Game or any reservation system.. help me plz
project
project  sir i want a java major project in railway reservation plz help me and give a project source code with entire validation thank you
j2me mysql connectivity
j2me mysql connectivity  I do a project on reservation using j2me. I need a connectivity to a MYSQL database. How do I do this Thanks and regards Karthiga
jsp code for allocating a room for a new guest
jsp code for allocating a room for a new guest  i am implementing a project on online hotel reservation system.please give code in jsp to allocate a room for a guest
Payment
Payment  Have to make payment by connecting to other sites how to do that..?? and also want to make booking history page for online reservation of cinemalls.can anyone plz help me
want a project
want a project  i want to make project in java on railway reservation using applets and servlets and ms access as database..please provide me code and how i can compile and run
assigning arraylist to combo box
assigning arraylist to combo box  Hi I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help
Moving Applet Problem
; Thread t1=new Thread(this); int maxx=0,maxy=0; Image plane...); setBackground(Color.BLACK); plane=getImage(getDocumentBase... public void paint(Graphics g) { g.drawImage(plane, maxx, maxy
surface chart - Java3D
surface chart  i have to make a surface chart of a piece of land with data given for each point in the xy plane....the chart should be such that the areas with different data range should show up in different colour. seriously
Advertisements
 

 

 

DMCA.com