Sie sind auf Seite 1von 25

Acknowledgement

Content
Introduction
Hardware Software
requirements
Code
import java.util.*;

class Hotel_Reservation_System

static Hotel_Reservation_System rev=new Hotel_Reservation_System();

Scanner in=new Scanner(System.in);

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 / Welcome to MAS Hotel ! \\");

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("\t1.\t\t Super Delux room");

System.out.println("\t2.\t\t Delux room");


System.out.println("\t3.\t\t AC room");

System.out.println("\t4.\t\t Non AC room");

System.out.println("\t5.\t\t Exit");

GregorianCalendar date=new GregorianCalendar();

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)

System.out.print("\tEnter 0 to select this room : ");

ch=in.nextInt();

System.out.print("\u000c");

switch(ch){

case 1:

c="Super Delux room";

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");

System.out.println("Choose any one of the following :");

System.out.println("S.no\t Bed Type\t Cost");

System.out.println("(1) \tSingle Bed\tRs"+amt);

System.out.println("(2) \tDouble Bed\tRs"+(amt+300));

bed=in.nextInt();

if(bed==1)

System.out.println("Thank You for selecting Single Bed "+c);

else if(bed==2){

amt+=300;

System.out.println("Thank You for selecting Double Bed "+c);

else if(bed!=1&&bed!=2){

System.out.print("Invalid Input! TRY AGAIN");

}}while(bed!=1&&bed!=2);

check=1;

rev.form();}}

else{

System.out.println("INVALID INPUT \uFFFD !");

System.out.print("Enter 1 to go to main menu or any other key to exit : ");

ca=in.nextInt();

if(ca!=1)

System.out.print("\t\t\t\t\t\t\t\t\t\t\tThanx for visiting !\u263A\u263B");

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\tCost per head : Rs"+amt+" for 24 hours(Single bed)");

System.out.println("\t\t\t\t\t\t\tLocation : "+location);

System.out.println("\t\t\t\t\t\t\tExtra facilities : # Swimming pool");

if(ch<3){

System.out.println("\t\t\t\t\t\t\t # free Wi-fi\u06dd");

if(ch==1){

System.out.println("\t\t\t\t\t\t\t # free room service on 1st day");

System.out.println("\t\t\t\t\t\t\t # 2 free movie tickets");}

System.out.println("\t\t\t\t\t\t\t # Free Cancellation");

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 | Form fill-up Section\t\t |");

System.out.println("\t\t\t\t\t\t\t\t |(Kindly fill the form in Capital letters only)|");

System.out.println("\t\t\t\t\t\t\t\t ************************************************");

do{

co=0;

System.out.print("Enter your First name :");

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)

System.out.println("INVALID INPUT \uFFFD !\nKINDLY TYPE IN CAPS !\n");

}while(co==1);

do{
co=0;

System.out.print("Enter your last name : ");

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)

System.out.println("INVALID INPUT \uFFFD !\nKINDLY TYPE IN CAPS !\n");

}while(co==1);

name=fnm+" "+lnm;

do{

System.out.print("Enter your Phone number : ");

mobno=in.next();

if(mobno.length()==10&&mobno.charAt(0)!='+')

break;

else if(mobno.charAt(0)=='+'&&mobno.length()==13)

break;

else{

System.out.println("INVALID PHONE NUMBER \uFFFD!\nPlease Try again !\n");

mobc=false;}}while(mobc==false);

do{

System.out.print("Enter 'M' for male or 'F' for female : ");

String g=in.next();

gen=g.charAt(0);

if(gen!='m'&&gen!='M'&&gen!='f'&&gen!='F'){

System.out.println("INVALID INPUT \uFFFD !");

System.out.print("Kindly Try again !\n");}

}while(gen!='m'&&gen!='M'&&gen!='f'&&gen!='F');

do{

System.out.print("Enter the Date of birth (Sample - 09/01/2003): ");

dob=in.next();

length=dob.length();

if(length!=10){

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

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.out.print("\t\t\t\t\t\t\t\tThanx for visiting Miss "+name+" !\u263A\u263B");

System.exit(0);}

break;

r=y%4;

if(d>31||m>12)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(r==0&&m==2&&d>29)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(r!=0&&m==2&&d>28)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(m==4||m==6||m==9||m==1){

if(d>30)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else

s=true; }

else

s=true;

}while(s==false);

s=false;

do{

System.out.print("Enter your Aadhar number : ");

adr=in.next();

if(adr.length()!=12)

System.out.println("INVALID Aadhar NUMBER \uFFFD!\nPlease Try again !\n");

}while(adr.length()!=12);

do{

System.out.print("Enter your email address : ");

email=in.next();

p=email.endsWith(".com");

q=email.endsWith(".COM");

if(p==false&&q==false)

System.out.println("INVALID EMAIL \uFFFD !\nKindly Try again");

}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){

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

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)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(r==0&&cim==2&&cid>29)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(r!=0&&cim==2&&cid>28)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy<cy)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy==cy&&cim==cm&&cid==cd)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy==cy&&cm>cim)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(cy==ciy&&cm==cim&&cd>=cid)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(cy==ciy&&cm>=cim&&cd>cid)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(cy==ciy&&cm==cim&&cd>cid)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(cim==4||cim==6||cim==9||cim==1){

if(cid>30)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else

s=true; }

else

s=true;

}while(s==false);

s=false;

do{

System.out.print("Enter the Date of Check out (Sample - 06/07/2019): ");

cout=in.next();
length=cout.length();

if(length!=10){

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

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)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(r==0&&com==2&&cod>29)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(r!=0&&com==2&&cod>28)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy>coy)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy==coy&&cim==com&&cid==cod)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy==coy&&cim>com&&cid<=cod)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy==coy&&cim==com&&cid>=cod)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(ciy==coy&&cim>com&&cid>=cod)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

else if(com==4||com==6||com==9||com==1){

if(cod>30)

System.out.println("INVALID DATE \uFFFD !\nPlease Try again !\n");

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();

System.out.print("Enter the no of children boarders : ");

noc=in.nextInt();

System.out.print("Enter the no of rooms required : ");

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| Terms & Condition |");

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\ta. Check-in time is 12 noon and check-out time is 10:00 am");

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\t After which 1 nights retention will be applicable");

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 their passport and valid visa.");

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 / Welcome to MAS Hotel !\t \\");

System.out.println("\t\t\t\t\t\t\t\t\t \\ Please have a glance on the bill /");

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\tName : Mrs "+name);


System.out.println("\t\t\t\t\t\t\t\t\t\tMobile Number : "+mobno);

System.out.println("\t\t\t\t\t\t\t\t\t\tE-mail : "+email);

System.out.println("\t\t\t\t\t\t\t\t\t\tRoom Package Booked : "+c);

System.out.println("\t\t\t\t\t\t\t\t\t\tCheck-in Date : "+cin);

System.out.println("\t\t\t\t\t\t\t\t\t\tCheck-out Date : "+cout);

System.out.println("\t\t\t\t\t\t\t\t\t\tNo. of Children Boarders to stay : "+noc);

System.out.println("\t\t\t\t\t\t\t\t\t\tNo. of Adult Boarders to stay : "+noa);

System.out.println("\t\t\t\t\t\t\t\t\t\tTotal no. of Boarders to stay : "+(noc+noa));

System.out.println("\t\t\t\t\t\t\t\t\t\tNo. of Rooms Booked : "+rooms);

System.out.println("\t\t\t\t\t\t\t\t\t\tGross Amount : Rs "+amt);

gst=Math.round(4/100.0*amt);

System.out.println("\t\t\t\t\t\t\t\t\t\tTotal Taxes : Rs."+gst);

System.out.println("\t\t\t\t\t\t\t\t\t\tTotal Amount to be paid : Rs."+(amt+gst));

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){

System.out.println("\t\t\t\t\t\t\t\t\t\tThank you for choosing cash !");

rev.fb();}

else if(pyn==2)

rev.card();

else

rev.exit();

void exit()

if(gen=='m'||gen=='M')

System.out.print("\t\t\t\t\t\t\t\tThanx for visiting Mr "+lnm+" !\u263A\u263B");

else if(gen=='f'||gen=='F')

System.out.print("\t\t\t\t\t\t\t\tThanx for visiting Mrs "+lnm+" !\u263A\u263B");

System.exit(0);}

void card()

String ac;

long pin2,pin,cho;

String cvc;

System.out.print("\u000c");

System.out.println("\t\t\t\t\t\tThank you for choosing Online Payment !");

do{
System.out.print("\t\t\t\t\t\tEnter your Account number : ");

ac=in.next();

if(ac.length()!=12)

System.out.println("\t\t\t\t\t\tINVALID ACCOUNT NUMBER \uFFFD!\n\t\t\t\t\t\tPlease Try again !\n");

}while(ac.length()!=12);

System.out.print("\t\t\t\t\t\tPlease Enter Card Holder's Name : ");

String na=in.next();

do{

System.out.println("\t\t\t\t\t\tPlease Choose your card type : ");

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)

System.out.println("\t\t\t\t\t\tINVALID CHOICE \uFFFD!\n\t\t\t\t\t\tPlease Try again !\n");

}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){

System.out.println("\t\t\t\t\t\tINVALID CVC \uFFFD !\n\t\t\t\t\t\tPlease Try again !\n");

continue;}

}while(cvc.length()!=3);

do{

s=false;

System.out.print("\n\t\t\t\t\t\tEnter the Date of Expiry (Sample - 09/01/2003): ");

dob=in.next();

length=dob.length();

if(length!=10){

System.out.println("\t\t\t\t\t\tINVALID DATE \uFFFD !\n\t\t\t\t\t\tPlease Try again !\n");

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)

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>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)

System.out.println("\t\t\t\t\t\tINVALID DATE \uFFFD !\n\t\t\t\t\t\tPlease Try again !\n");

else if(m==4|m==6||m==9||m==1){

if(d>30)

System.out.println("\t\t\t\t\t\tINVALID DATE \uFFFD !\n\t\t\t\t\t\tPlease Try again !\n");

else

s=true; }

else

s=true;

}while(s==false);

if(cy>y){

System.out.println("\t\t\t\t\t\tEXPIRED CARD \uFFFD !\n\t\t\t\t\t\t\t\tPAYMENT DECLINED !\n");

rev.exit();}

else if(y==cy&&m<cm){

System.out.println("\t\t\t\t\t\tEXPIRED CARD \uFFFD !\n\t\t\t\t\t\t\t\tPAYMENT DECLINED !\n");

rev.exit();}

else if(y==cy&&m==cm&&d<=cd){

System.out.println("\t\t\t\t\t\tEXPIRED CARD \uFFFD !\n\t\t\t\t\t\t\t\tPAYMENT DECLINED !\n");

rev.exit();}

System.out.println("\t\t\t\t\t\tWe are going to transact Rs "+amt+" from your account !");

System.out.print("\t\t\t\t\t\tEnter 'c' for confirmation : ");

String cz=in.next();

char conf=cz.charAt(0);

if(conf=='c'||conf=='C')

System.out.println("\t\t\t\t\t\tYou have successfully booked a "+c+"\n");

else

System.out.println("\t\t\t\t\t\t\t\tPAYMENT DECLINED !");

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 !");

System.out.print("\t\t\t\t\t\tKindy rate us out of 10 stars : ");

int fb=in.nextInt();

if(fb<5)

System.out.println("\t\t\t\t\t\tSorry for the Inconvenience, we'll try to improve !");

else if(fb>=5&&fb<=7)

System.out.println("\t\t\t\t\t\tSorry for little Inconvenience, we'll try to improve !");


else

System.out.println("\t\t\t\t\t\tWe are very thankful for giving us wonderfull response !");

rev.exit();

public static void main(String args[])

rev.header();

rev.choices();

Das könnte Ihnen auch gefallen