dear friends i am a student of 11 th and this was a project given to me by my teacher I chose hotel management and developed the code from scratch well she helped me for generating the random number for the room using randomize() from stdlib.h but it did not work and upon searching i found only rand() but even with that it is not working please help any suggestion is welcome.
here is the code
Code:
#include
<iostream.h>
#include
<stdio.h>
#include
<iomanip.h>
#include
<string.h>
#include
<stdlib.h>
#include
<conio.h>
#include
<time.h>
struct
customer
{
int pr;
char
fname[20];
char
lname[20];
char
nation[15];
long
mob;
long
totalbill;
};
void
randm (int y)
{
int
num[20], u=y*100,flag=0,w;
long
z;
for
(w=0;w<20;w++)
{
do
{
z=rand()%(20);
z+=u;
for
(int v=0;v<=w;v++)
if
(z==num[v])
flag=1;
}
while(flag!=0);
}
if
(flag==0)
{
num[w]=z;
cout<<
"room number is "<<z<<endl;
}
}
void
main()
{srand(
unsigned(time(NULL)));
clrscr();
customer cs[200];
int
i,h,d,t,r,e,f,b,x,g;
cout<<
"starting program"<<endl;
cout<<
"enter 1 to start booking"<<endl;
cout<<
"enter 3 to exit"<<endl;
cin>>x;
cout<<endl;
do
{
for
(i=0;i<200;i++)
{
cs[i].totalbill=0;
cout<<
"__________________________________________________________________________"<<endl;
cout<<
" Welcome to Hotel Naraveru "<<endl;
cout<<
"___________________________________________________________________________"<<endl;
cout<<
"Get ready to enter details"<<endl;
cout<<
"What type of booking do u want to make?"<<endl;
cout<<
"enter 1 for party hall"<<endl;
cout<<
"enter 2 for room booking"<<endl;
cout<<
"enter 3 to exit"<<endl;
cin>>cs[i].pr;
switch
(cs[i].pr)
{
case 1:cout<<"enter first name"<<endl;
gets (cs[i].fname);
cout<<
"enter last name"<<endl;
gets (cs[i].lname);
cout<<
"enter the mobile number "<<endl;
cin>>cs[i].mob;
cout<<endl;
cout<<
"enter 1 for grand hall costts 1050 for one day"<<endl;
cout<<
"enter 2 for small hall costs 550 for one day "<<endl;
cin>>h;
if
(h==1)
{cout<<
"please enter number of days you want the hall for"<<endl;
cin>>d;
cout<<endl;
cs[i].totalbill=d*1050;
cout<<
"do you want beverages from the hotel costs 150 enter 1 for yes or 2 for no"<<endl;
cin>>b;
cout<<endl;
if
(b==1)
{t=150*d;
cs[i].totalbill+=t;
}
cout<<
"booking confirmed"<<endl;
cout<<
"dear customer so total bill= "<<cs[i].totalbill<<endl;
}
if
(h==2)
{cout<<
"please enter number of days you want the hall for "<<endl;
cin>>d;
cout<<endl;
cs[i].totalbill=d*550;
cout<<
"do you want beverage from the hotel costs 150 enter 1 for y or 2 for n"<<endl;
cin>>b;
cout<<endl;
if
(b==1)
{t=b*d;
cs[i].totalbill+=t;
}
cout<<
"booking confirmed"<<endl;
cout<<
"dear customer so total bill= "<<cs[i].totalbill<<endl;
}
break
;
case
2:cout<<"enter first name"<<endl;
gets (cs[i].fname);
cout<<endl;
cout<<
"enter last name"<<endl;
gets (cs[i].lname);
cout<<endl;
cout<<
"enter mobile number"<<endl;
cin>> cs[i].mob;
cout<<endl;
cout<<
"enter nationality "<<endl;
gets (cs[i].nation);
cout<<endl;
cout<<
" enter 1 for standard room costs 850 per day"<<endl;
cout<<
" enter 2 for deluxe room costs 1250 per day"<<endl;
cout<<
" enter 3 for super deluxe room costs 2250 per day"<<endl;
cout<<
" enter 4 for king room costs 4500 per day"<<endl;
cout<<
"enter the number for your choice of room "<<endl;
cin>>r;
switch
(r)
{
case 1: cout<<"so you have chosen standard room"<<endl;
cout<<
"enter number of days"<<endl;
cin>>d;
cout<<endl;
cs[i].totalbill= d* 850;
cout<<
"enter the floor number 1,2,3 or 4 "<<endl;
cin>>e;
cout<<endl;
randm(e);
break
;
case
2:cout<<"so you have chosen deuluxe room"<<endl;
cout<<
"enter number of days"<<endl;
cin>>d;
cout<<endl;
cs[i].totalbill=d*1250;
cout<<
"enter the floor number 5 or 6"<<endl;
cin>>e;
cout<<endl;
randm(e);
break
;
case
3:cout<<"so you have chosen super deluxe room"<<endl;
cout<<
"enter number of days"<<endl;
cin>>d;
cout<<endl;
cs[i].totalbill=d*2250;
cout<<
"enter the floor number 7 or 8"<<endl;
cin>>e;
cout<<endl;
randm(e);
break
;
case
4:cout<<"so you have chosen king room"<<endl;
cout<<
"enter number of days"<<endl;
cin>>d;
cout<<endl;
cs[i].totalbill=d*4500;
cout<<
"enter the floor number 9 or 10"<<endl;
cin>>e;
cout<<endl;
randm(e);
break
;
default
:cout<<"Please enter a valid choice"<<endl;
}
cout<<
"do you want swimming pool and spa service costs 350 per day (1 for y / 2 for n)?"<<endl;
cin>>b;
cout<<endl;
if
(b==1)
{t=350*d;
cs[i].totalbill+=t;
}
cout<<
"do you want television service costs 100 (1 for y/ 2 for n)?"<<endl;
cin>>b;
cout<<endl;
if
(b==1)
{t=100*d;
cs[i].totalbill+=t;
}
cout<<
"enter 1 for only breakfast costs 50"<<endl;
cout<<
"enter 2 for only brakfast and dinner costs 100"<<endl;
cout<<
"enter 3 for whole package costs 150"<<endl;
cin>>f;
cout<<endl;
switch
(f)
{
case 1:cout<<"You have chosen the first option"<<endl;
t=50*d;
cs[i].totalbill+=t;
break
;
case
2:cout<<"You have chosen the second option"<<endl;
t=100*d;
cs[i].totalbill+=t;
break
;
case
3:cout<<"You have chosen the third option"<<endl;
t=150*d;
cs[i].totalbill+=t;
break
;
default
:cout<<"please enter a valid choice "<<endl;
}
cout<<
"Last but not the least do u want taxi service costs 75 per day (1 for y/ 2 for n)?"<<endl;
cin>>b;
cout<<endl;
if
(b==1)
{t=75*d;
cs[i].totalbill+=t;
}
cout<<
"your booking has been confirmed"<<endl;
cout<<
"here are the details"<<endl;
cout<<
"name:-"<<cs[i].fname<<cs[i].lname<<endl;
cout<<
"mobile number is"<<endl;
cout<<cs[i].mob;
cout<<
"and your room type is:-"<<endl;
if
(r==1)
cout<<
"standard room"<<endl;
if
(r==2)
cout<<
"deluxe room"<<endl;
if
(r==3)
cout<<
"super deluxe room"<<endl;
if
(r==4)
cout<<
"king room"<<endl;
cout<<
"Dear customer your total bill is"<<cs[i].totalbill<<endl;
cout<<
"Please do come again after this visit we will be more than happy to entertain you"<<endl;
break
;
case
3:exit(0);
default
: cout<<"Please enter a valid choice"<<endl;
}
}
}
while(x!=3);
}