Newjk
Newjk
package javalib; import javax.swing.JOptionPane; import javax.swing.JTextArea; public class reservation1 { public static String ac_first_class[]=new String[10]; public static String ac_2nd_class[]=new String[10]; public static String ac_3rd_class[]=new String[10]; public static String sleeper[]=new String[10]; public static void main(String args[]) {
String output="Enter 1 for ac_first_class\n"+"Enter 2 for ac_2nd_class\n"+"Enter 3 for ac_3rd_class\n"+"Enter 4 for sleeper\n"+"Enter 5 for show seat info\n"+"Enter 6 for exit\n"; JOptionPane.showMessageDialog(null,output,"ReservationSystem",JOptionPane.INFORMATION_ME SSAGE); int i=0,j=0,k=0,l=0; String ch=JOptionPane.showInputDialog("Enter a choice"); int choice=Integer.parseInt(ch); while(choice !=6) { switch(choice) { case 1: if(i>10 )
{ JOptionPane.showMessageDialog(null,"All seats are book in ac_first_class section"+" Do u want a seat in sleeper"); break;} ac_first_class(i); i++; break; case 2: if(j>10){ JOptionPane.showMessageDialog(null,"All seats are book in ac_2nd_class section"+"Do u want a seat in ac"); break;} ac_2nd_class(j); j++; break; case 3: if(k>10) { JOptionPane.showMessageDialog(null,"All seats are book in ac_3rd_class section"+"Do u want a seat in ac"); break; } ac_3rd_class(k); k++; break; case 4: if(l>10)
{ JOptionPane.showMessageDialog(null,"All seats are book in sleeper section"+"Do u want a seat in ac"); break; } sleeper(l); l++; break; case 5: status(); break; default: JOptionPane.showMessageDialog(null,"You enter awrong choice"+"enteragain"); } ch=JOptionPane.showInputDialog("Enter a choicen"); choice=Integer.parseInt(ch); } System.exit(0); } public static void ac_first_class(int x) { /* { break; }*/ String name=JOptionPane.showInputDialog("Enter passsenger name"); ac_first_class[x]=name; if(x>4)
int y=x; String output="\npassenger name--"+name+"\nseat no--"+(y+1)+"\nac_first_class section"; JOptionPane.showMessageDialog(null,output,"Boarding Pass",JOptionPane.INFORMATION_MESSAGE); } public static void ac_2nd_class(int q) { /* break; }*/ String name=JOptionPane.showInputDialog("Enter passsenger name"); ac_2nd_class[q]=name; int y=q; String output="\npassenger name--"+name+"\nseat no--"+(y+1)+"\nac_2nd_class section"; JOptionPane.showMessageDialog(null,output,"Boarding Pass",JOptionPane.INFORMATION_MESSAGE); } public static void ac_3rd_class(int r) { /* break; }*/ String name=JOptionPane.showInputDialog("Enter passsenger name"); ac_3rd_class[r]=name; int y=r; String output="\npassenger name--"+name+"\nseat no--"+(y+1)+"\nac_3rd_class if(x>4){ if(x>4){
section"; JOptionPane.showMessageDialog(null,output,"Boarding Pass",JOptionPane.INFORMATION_MESSAGE); } public static void sleeper(int y) { String name=JOptionPane.showInputDialog("Enter passenger name"); sleeper[y]=name; int z=y; String output="passenger name--"+name+"\nseat no--"+(z+1)+"\nsleeper section"; JOptionPane.showMessageDialog(null,output,"BoardingPass",JOptionPane.INFORMATI ON_MESSAGE); } public static void status() { int t; JTextArea outputArea=new JTextArea(20,30); outputArea.append("seat_no sleeper"); for( t=0;t<10;t++) outputArea.append("\n"+" "+(t+1)+" "+" "+ac_first_class[t]+" "+ac_2nd_class[t]+" "+ac_3rd_class[t]+" "+sleeper[t]+" "+"\n"); ac_first_class ac_2nd_class ac_3rd_class
JOptionPane.showMessageDialog(null,outputArea,"seatinfo",JOptionPane.INFORMATION_MESSAGE) } }