This project reserves the seats for passengers for different categories:
smoking or non smoking

SOURCE CODE:



import javax.swing.JOptionPane;
import javax.swing.JTextArea;

public class Reservation
{

    public static int smoke[]=new int[5];
public static int nonsmoke[]=new int[5];
public static void main(String args[])
{
String output=("Enter 0 for smoking"+"Enter 1 for nonsmoke Enter 3 for seats info"+"enter 4 for Exit");
                JOptionPane.showMessageDialog(null,output,"Reservation System",JOptionPane.INFORMATION_MESSAGE);
String c=JOptionPane.showInputDialog("Enter a choice");
int ch=Integer.parseInt(c);
int i=0,j=0;
while(ch !=4)
{
switch(ch)
{

case 0:
if(i>4 ){
JOptionPane.showMessageDialog(null,"All seats are book in smoking section"+ " Do u want a seat in nonsmoke");

                                                            break;}
          smoke(i);
i++;
break;
case 1:
        if(j>4){
JOptionPane.showMessageDialog(null,"All seats are book in nonsmoking section"+"Do u want a seat in smoking");
break;
                                                }

  nonsmoke(j);
  j++;
  break;
case 3:
  status();
  break;
default:

JOptionPane.showMessageDialog(null,"You enter awrong choice"+"enter again");

}
       c=JOptionPane.showInputDialog("Enter a choice");
    ch=Integer.parseInt(c);
}
System.exit(0);
}
public static void smoke(int a)
{
/* if(a>4){

break;
}*/

String sname=JOptionPane.showInputDialog("Enter pas name");

smoke[a]=1;
String output="passenger name--"+sname+"seat no--"+a+"Smoking section";

JOptionPane.showMessageDialog(null,output,"Boarding Pass",JOptionPane.INFORMATION_MESSAGE);

}
public static void nonsmoke(int b)
        {
String name=JOptionPane.showInputDialog("Enter pas name");

nonsmoke[b]=1;
String output="passenger name--"+name+"seat no--"+b+"NonSmoking section";

JOptionPane.showMessageDialog(null,output,"Boarding Pass",JOptionPane.INFORMATION_MESSAGE);
}
public static void status()
{
int c;
JTextArea outputArea=new JTestArea(20,30);
outputArea.append("Smoking nonSmoking");
for( c=0;c<5;c++)
outputArea.append(smoke[c]+" "+nonsmoke[c]+" ");
JOptionPane.showMessageDialog(null,outputArea,"seatinfo",JOptionPane.INFORMATION_MESSAGE);


}

}



0 comments to "PROJECT ON RESERVATION"

Post a Comment

Powered by Blogger.