Beruflich Dokumente
Kultur Dokumente
Content
Introduction
Hardware Software
requirements
Code
import java.util.*;
class Hotel_Reservation_System
int d,m,y,cd,cm,cy,noa,noc,days,rooms,amt,bed;
String fnm,lnm,name,mobno,email,adr,dob,cin,cout;
char gen;
int length,r,cid,cim,ciy,cod,com,coy,tc,pyn=3,hr,min,sec;
String c;
double gst;
boolean p,q,s=false;
void header()
System.out.println("\t\t\t\t\t\t\t\t\t /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\");
System.out.println("\t\t\t\t\t\t\t\t\t \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/");
void choices()
int check=0,ch=1,count=0;
c="";
String location="";
do{
if(ch!=0)
check=0;
System.out.print("\n\n\n\n\tChoose any one of the following to view the facilities and cost :\n\t");
for(int i=1;i<=50;i++)
System.out.print("-");
System.out.println("\n\n");
System.out.println("\n\tS.No\t\tRoom type");
System.out.println("\t5.\t\t Exit");
cd=date.get(Calendar.DATE);
cm=date.get(Calendar.MONTH);
cm++;
cy=date.get(Calendar.YEAR);
hr=date.get(Calendar.HOUR);
min=date.get(Calendar.MINUTE);
sec=date.get(Calendar.SECOND);
if(hr==0)
hr=12;
System.out.println("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDate: "+cd+"/"+cm+"/"+cy);
System.out.println("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTime: "+hr+":"+min+":"+sec+"\u231a");
if(count>=1&&ch!=5&&ch!=5)
ch=in.nextInt();
System.out.print("\u000c");
switch(ch){
case 1:
amt=5000;
location="Fourth Floor";
break;
case 2:
c="Delux room";
amt=4000;
location="Third Floor";
break;
case 3:
c="AC room";
amt=2500;
location="Second Floor";
break;
case 4:
c="Non AC room";
amt=1000;
location="First Floor";
break;
case 5:
System.out.print("Are you sure you want to exit?\n Enter 1 to confirm OR any other digit for Main Menu : ");
int ca=in.nextInt();
if(ca==1)
rev.exit();
break;
default:
if(c!=""){
if(ch==0){
do{
System.out.print("\u000c");
bed=in.nextInt();
if(bed==1)
else if(bed==2){
amt+=300;
else if(bed!=1&&bed!=2){
}}while(bed!=1&&bed!=2);
check=1;
rev.form();}}
else{
ca=in.nextInt();
if(ca!=1)
System.exit(0);}}}
if(ch==1||ch==2||ch==3||ch==4||ch==5){
rev.header();
count++;
if(ch==6)
continue;
System.out.print("\t\t\t\t\t\t ");
for(int i=1;i<=67;i++)
System.out.print("*");
System.out.println("\n");
System.out.println("\t\t\t\t\t\t\t\t\t\tBooking of "+c+"\n");
System.out.println("\t\t\t\t\t\t\tLocation : "+location);
if(ch<3){
if(ch==1){
System.out.print("\n\t\t\t\t\t\t ");
for(int i=1;i<=67;i++)
System.out.print("*");
System.out.println();}
}while(check==0);
void form()
int co=0;
boolean mobc=true;
System.out.println("\t\t\t\t\t\t\t\t ***********************************************");
System.out.println("\t\t\t\t\t\t\t\t ************************************************");
do{
co=0;
fnm=in.next();
for(int l=fnm.length()-1;l>=0;l--){
if(fnm.charAt(l)<65||fnm.charAt(l)>90)
co=1;}
if(co==1)
}while(co==1);
do{
co=0;
lnm=in.next();
for(int l=lnm.length()-1;l>=0;l--){
if(lnm.charAt(l)<65||lnm.charAt(l)>90)
co=1;}
if(co==1)
}while(co==1);
name=fnm+" "+lnm;
do{
mobno=in.next();
if(mobno.length()==10&&mobno.charAt(0)!='+')
break;
else if(mobno.charAt(0)=='+'&&mobno.length()==13)
break;
else{
mobc=false;}}while(mobc==false);
do{
String g=in.next();
gen=g.charAt(0);
if(gen!='m'&&gen!='M'&&gen!='f'&&gen!='F'){
}while(gen!='m'&&gen!='M'&&gen!='f'&&gen!='F');
do{
dob=in.next();
length=dob.length();
if(length!=10){
continue;}
d=Integer.parseInt(dob.substring(0,2));
m=Integer.parseInt(dob.substring(3,5));
y=Integer.parseInt(dob.substring(6));
if(cy-y<18){
if(gen=='m'||gen=='M'){
System.out.println("Dear Bro! You are not eligible to book a room according to our protocols !");
rev.exit();}
if(gen=='f'||gen=='F'){
System.out.println("Dear girl! You are not eligible to book a room according to our protocols !");
System.exit(0);}
break;
r=y%4;
if(d>31||m>12)
else if(r==0&&m==2&&d>29)
else if(r!=0&&m==2&&d>28)
else if(m==4||m==6||m==9||m==1){
if(d>30)
else
s=true; }
else
s=true;
}while(s==false);
s=false;
do{
adr=in.next();
if(adr.length()!=12)
}while(adr.length()!=12);
do{
email=in.next();
p=email.endsWith(".com");
q=email.endsWith(".COM");
if(p==false&&q==false)
}while(p==false&&q==false);
do{
s=false;
System.out.print("Enter the Date of Check in (Sample - 06/07/2019): ");
cin=in.next();
length=cin.length();
if(length!=10){
continue;}
cid=Integer.parseInt(cin.substring(0,2));
cim=Integer.parseInt(cin.substring(3,5));
ciy=Integer.parseInt(cin.substring(6));
r=ciy%4;
if(cid>31||cim<1||cim>12)
else if(r==0&&cim==2&&cid>29)
else if(r!=0&&cim==2&&cid>28)
else if(ciy<cy)
else if(ciy==cy&&cim==cm&&cid==cd)
else if(ciy==cy&&cm>cim)
else if(cy==ciy&&cm==cim&&cd>=cid)
else if(cy==ciy&&cm>=cim&&cd>cid)
else if(cy==ciy&&cm==cim&&cd>cid)
else if(cim==4||cim==6||cim==9||cim==1){
if(cid>30)
else
s=true; }
else
s=true;
}while(s==false);
s=false;
do{
cout=in.next();
length=cout.length();
if(length!=10){
continue;}
cod=Integer.parseInt(cout.substring(0,2));
com=Integer.parseInt(cout.substring(3,5));
coy=Integer.parseInt(cout.substring(6));
r=coy%4;
if(cod>=31||com<1||com>12)
else if(r==0&&com==2&&cod>29)
else if(r!=0&&com==2&&cod>28)
else if(ciy>coy)
else if(ciy==coy&&cim==com&&cid==cod)
else if(ciy==coy&&cim>com&&cid<=cod)
else if(ciy==coy&&cim==com&&cid>=cod)
else if(ciy==coy&&cim>com&&cid>=cod)
else if(com==4||com==6||com==9||com==1){
if(cod>30)
else
s=true; }
else
s=true;
}while(s==false);
if(cid>cod){
com--;
cod+=30;}
days=cod-cid;
if(cim>com){
coy--;
com+=12;}
days+=((com-cim)*30)+((coy-ciy)*365);
System.out.print("Enter the no of adult boarders : ");
noa=in.nextInt();
noc=in.nextInt();
rooms=in.nextInt();
System.out.print("\u000c");
System.out.println("\t\t\t\t\t\t\t\t################################################");
System.out.println("\t\t\t\t\t\t\t\t################################################");
System.out.println("\t\t\t\t----------------------------------------------------------------------------------------------------------");
System.out.println("\t\t\t\t1. General Check-in / Check-out Policy is as per below (this may vary for certain hotels):");
System.out.println("\t\t\t\tb. Subject to availability, early check-in and late check-out will be considered. Charges as applicable");
System.out.print("\t\t\t\t2. In case of cancellation of booking 48 hours prior to arrival (72 hours prior for some hotels) \n\t\t\t\t no cancellation charges apply.");
System.out.println("\t\t\t\t3. Children up-to 15 Years of age can stay free (cribs subject to availability).");
System.out.println("\t\t\t\t4. In keeping with our heightened security procedures we request you to provide your photo-identity");
System.out.println("\t\t\t\t proof while checking-in. Indian Nationals can present any of the following which is mandatory :");
System.out.println("\t\t\t\t Passport, Driving License, Voter ID Card, Pan Card. Foreign Nationals are required to present ");
System.out.println("\t\t\t\t___________________________________________________________________________________________________________");
System.out.print("\n\nEnter 1 to accept the terms and conditions or any other key to exit : ");
tc=in.nextInt();
if(tc==1){
rev.bill();}
else{
rev.exit();}}
void bill()
System.out.print("\u000c");
amt=amt*days*noa*rooms+(amt*days*noc*rooms)/2;
System.out.println("\t\t\t\t\t\t\t\t\t /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\");
System.out.println("\t\t\t\t\t\t\t\t\t \\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/");
if(gen=='m'||gen=='M')
System.out.println("\t\t\t\t\t\t\t\t\t\tName : Mr "+name);
else
System.out.println("\t\t\t\t\t\t\t\t\t\tE-mail : "+email);
gst=Math.round(4/100.0*amt);
System.out.println("\t\t\t\t\t\t\t\t\t\t\t\t\t\tDate: "+cd+"/"+cm+"/"+cy);
System.out.println("\t\t\t\t\t\t\t\t\t\t\t\t\t\tTime: "+hr+":"+min+":"+sec+"\u231a");
System.out.print(" Choose the mode of payment OR any other digit to exit without booking : \n 1.Pay at Hotel \n 2. Online Payment ");
pyn=in.nextInt();
if(pyn==1){
rev.fb();}
else if(pyn==2)
rev.card();
else
rev.exit();
void exit()
if(gen=='m'||gen=='M')
else if(gen=='f'||gen=='F')
System.exit(0);}
void card()
String ac;
long pin2,pin,cho;
String cvc;
System.out.print("\u000c");
do{
System.out.print("\t\t\t\t\t\tEnter your Account number : ");
ac=in.next();
if(ac.length()!=12)
}while(ac.length()!=12);
String na=in.next();
do{
System.out.println("\n\t\t\t\t\t\t1.\tCredit Card");
System.out.println("\t\t\t\t\t\t2.\tDebit Card");
System.out.println("\t\t\t\t\t\t3.\tDinners Club");
System.out.println("\t\t\t\t\t\t4.\tVisa");
System.out.println("\t\t\t\t\t\t5.\tMaster Card");
cho=in.nextInt();
if(cho!=1&&cho!=2&&cho!=3&&cho!=4&&cho!=5)
}while(cho!=1&&cho!=2&&cho!=3&&cho!=4&&cho!=5);
do{
System.out.print("\t\t\t\t\t\tPlease Enter CVC (Last 3 digits printed on the back of the card) : ");
cvc=in.next();
if(cvc.length()!=3){
continue;}
}while(cvc.length()!=3);
do{
s=false;
dob=in.next();
length=dob.length();
if(length!=10){
continue;}
d=Integer.parseInt(dob.substring(0,2));
m=Integer.parseInt(dob.substring(3,5));
y=Integer.parseInt(dob.substring(6));
r=y%4;
if(d>31||m>12)
else if(r==0&&m==2&&d>29)
System.out.println("\t\t\t\t\t\tINVALID DATE \uFFFD !\n\t\t\t\t\t\tPlease Try again !\n");
else if(r!=0&&m==2&&d>28)
else if(m==4|m==6||m==9||m==1){
if(d>30)
else
s=true; }
else
s=true;
}while(s==false);
if(cy>y){
rev.exit();}
else if(y==cy&&m<cm){
rev.exit();}
else if(y==cy&&m==cm&&d<=cd){
rev.exit();}
String cz=in.next();
char conf=cz.charAt(0);
if(conf=='c'||conf=='C')
else
rev.fb();
rev.exit();
void fb()
System.out.println("\n\t\t\t\t\t\tWe would like to know How much you loved our service !");
int fb=in.nextInt();
if(fb<5)
else if(fb>=5&&fb<=7)
rev.exit();
rev.header();
rev.choices();