Please complete this program in c Create a hotel reservation program with the fo
ID: 646634 • Letter: P
Question
Please complete this program in c
Create a hotel reservation program with the following parameters:
The hotel has 20, 30, 40, or 50 rooms.
For each room you have to store the following information:
Room number. (assigned by program)
Room rate. (entered by user)
Smoking or non-smoking. (entered by user, max 8 per hotel)
Customer Id (if room is reserved). (entered by user)
Number of days reserved. (entered by user)
Prompt the user to enter the number of rooms in the hotel and create a two dimensional array (of variables type double) that fits the exact number entered. If the user enters a number other than 20, 30, 40, or 50, display an invalid input message and re-prompt the user to enter the right number.
Populate the room numbers as follows: the first 10 rooms numbered from 101 to 110, the second ten rooms numbered 201 to 210, and so forth. Use a function, roomNum, to assign the room numbers using loops. Initialize all other array locations to zero.
Display a menu asking the user for the following options:
A to add reservation.
C to cancel reservation.
R to retrieve reservation.
T to display all reservations.
X to exit program.
Adding reservation should be done with a function named addReservation. The user is asked first whether this will be smoking or nonsmoking and the availability of room is determined before adding the room (there are eight smoking rooms in any hotel, they could be any rooms, but a total of eight). If the room is available (not reserved), then the user is prompted to enter the rest of the reservation info, otherwise, display a message saying all rooms are reserved.
Cancel reservation will ask for the customer Id and free the rooms reserved by the customer (hint, a customer could reserve more than one room). This option is performed by a function named cancelReservation.
Retrieve reservation will ask for a customer Id and retrieve all the information for the rooms reserved by the customer, including the total cost of the hotel stay for the specific customer (tax is 12%). This option is performed by a function named retrieveReservation.
Display all reservations will display the information for all reservations by room number, and the total amount charged for all reservations, tax included. This option is performed by a function named displayAll.
Since the reservations could be cancelled, it is assumed that the array will not be uniformly filled. The addReservation function should add new reservations in the first available room in the array, for which the customer id would be zero.
Cancelling a reservation is done by setting all the fields except the room number to zero.
To indicate that a room is smoking, enter 1 for smoking, 0 for non-smoking.
Only function calls are allowed to execute menu options.
Array arguments passed to functions could be done with or without pointers, it is up to the programmer.
Explanation / Answer
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
//Global variables............
int advance[5]={750,500,400,500,750};
int r_no[5]={1,2,3,4,5};
int room;
tot[5]={0,0,0,0,0};
int g_tot=0;
int r_charge[5];
char r_type[5][7];
char r_cust[5][20]={"N.A","N.A","N.A","N.A","N.A"};
char c_city[5][20];
char name[30];
int c_mem[5];
char c_nat[5][20];
char r_avail[5];
int r_per[5];
int no[5];
int year[5];
int month[5];
int day[5];
int i;
//Function prototypes.........
void getavail();
void putavail();
void features();
void allocate();
void putcust();
void restaurant();
void deallocate();
void cancel();
void intro();
void screenheader();
//Function definitions..........
void screenheader()
{
printf(" :::::::::::::::::::::::::::::::::::::");
printf(" :: ::");
printf(" :: @@@@@@@@@@@@@@@@@@@@@@@ ::");
printf(" :: @ @ ::");
printf(" :: @ WELCOME TO @ ::");
printf(" :: @ @ ::");
printf(" :: @ Lovely Coding @ ::");
printf(" :: @ @ ::");
printf(" :: @@@@@@@@@@@@@@@@@@@@@@@ ::");
printf(" :: ::");
printf(" ::::::::::::::::::::::::::::::::::::: ");
}
void intro()
{
printf(" Near BSF Chowk, G.T. Road, Jalandhar City, Punjab 144001, INDIA");
printf(" Ph. No.:011-27223959");
printf(" WELCOMES YOU..............");
printf(" Hotel Ganga Inn is one of the newest Hotel in Jalandhar. The Hotel is equipped with with all the general amenities and facilities that go along with memorable stay. Set amidst beautifully landscaped gardens, it proves to be a ideal dream destination for perceptive traveller.");
printf(" The Hotel have well furnished rooms along with rooms providing pleasent views of the city. The hotel satisfies the needs of business as well as the leisure traveller. All the rooms at the thotel are furnished beautifully. All the rooms are fitted with amenities.");
printf(" AMENITIES ....... ");
printf(" 1. 100% Power backup. ");
printf(" 2. Automatic lift. ");
printf(" 3. Ample parking space. ");
printf(" 4. Round the clock security. ");
printf(" 5. Running hot and cold water. ");
printf(" 6. Free internet service. ");
printf(" 7. 24 hours room service. ");
printf(" 8. Laundary service. ");
printf(" Press any character to continue:");
getch();
}
void getavail()
{
for(i=0;i<5;i++)
{
if(r_no[i]==1)
{
strcpy(r_type[i],"Sp Dlx");
r_charge[i]=1500;
if(strcmp(r_cust[i],"N.A")==0)
{
r_avail[i]='Y';
r_per[i]=0;
}
}
else if(r_no[i]==2)
{
strcpy(r_type[i],"Dlx");
r_charge[i]=1000;
if(strcmp(r_cust[i],"N.A")==0)
{
r_avail[i]='Y';
r_per[i]=0;
}
}
else if(r_no[i]==3)
{
strcpy(r_type[i],"Gen");
r_charge[i]=750;
if(strcmp(r_cust[i],"N.A")==0)
{
r_avail[i]='Y';
r_per[i]=0;
}
}
else if(r_no[i]==4)
{
strcpy(r_type[i],"Coupl");
r_charge[i]=1000;
if(strcmp(r_cust[i],"N.A")==0)
{
r_avail[i]='Y';
r_per[i]=0;
}
}
else if(r_no[i]==5)
{
strcpy(r_type[i],"C Dlx");
r_charge[i]=1500;
if(strcmp(r_cust[i],"N.A")==0)
{
r_avail[i]='Y';
r_per[i]=0;
}
}
}
}
void putavail()
{
clrscr();
screenheader();
printf(" ROOM AVAILABILITY");
printf(" -------------------");
printf(" Room No| Type | Charge | Availability | Cust_Name | Period |");
for(i=0;i<5;i++)
{
printf(" %d ",r_no[i]);
cputs(r_type[i]);
if(i==0)
printf(" %d %c ",r_charge[i],r_avail[i]);
if((i==1) || (i==2))
printf(" %d %c ",r_charge[i],r_avail[i]);
if(i==3 || i==4)
printf(" %d %c ",r_charge[i],r_avail[i]);
cputs(r_cust[i]);
if((i==1) || (i==2))
printf(" %d",r_per[i]);
else if((i==3) || (i==4))
printf(" %d",r_per[i]);
else
printf(" %d",r_per[i]);
}
}
void features()
{
int typ;
clrscr();
screenheader();
printf(" Choose the room type: 1. Sp. Delux 2. Delux");
printf(" 3. General 4. Couple 5. C. Delux ");
scanf("%d",&typ);
if(typ>5)
{
printf(" Wrong choice!! Choose a number between 1-5:");
features();
}
switch(typ)
{
case 1:clrscr();
screenheader();
printf(" Room number >>>1");
printf(" Advance >>>750 ");
printf(" FEATURES OF THIS ROOM ");
printf(" ------------------------------------------------------------------");
printf(" Room Type >>> Sp.delux");
printf(" Room charges >>> Rs.1500 per day");
printf(" 1. Bed >>> 2");
printf(" 2.Capacity >>> 5");
printf(" 3.Balcony available ");
printf(" ------------------------------------------------------------------");
printf(" ADDITIONAL FEATURES ");
printf(" ------------------------------------------------------------------");
printf(" 1.A/C available ");
printf(" 2.Geyser available");
printf(" 3.TV available ");
printf(" ------------------------------------------------------------------");
printf(" NOTE :- Extra bed will cost Rs.50 per bed ");
break;
case 2:clrscr();
screenheader();
printf(" Room number >>>2 ");
printf(" Advance >>>500 ");
printf(" FEATURES OF THIS ROOM ");
printf(" -------------------------------------------------------------------");
printf(" Room Type >>> Delux ");
printf(" Room charges >>>Rs.1000 per day");
printf(" 1. Bed >>> 2");
printf(" 2.Capacity >>> 5");
printf(" -------------------------------------------------------------------");
printf(" ADDITIONAL FEATURES ");
printf(" -------------------------------------------------------------------");
printf(" 1.A/C available ");
printf(" 2.Geyser available");
printf(" 3.TV available ");
printf(" -------------------------------------------------------------------");
printf(" NOTE :- Extra bed will cost Rs.50 per bed ");
break;
case 3:clrscr();
screenheader();
printf(" Room number >>>3 ");
printf(" Advance >>>400 ");
printf(" FEATURES OF THIS ROOM ");
printf(" -------------------------------------------------------------------");
printf(" Room Type >>> General ");
printf(" Room charges >>>Rs.750 per day");
printf(" 1. Bed >>> 2");
printf(" 2.Capacity >>> 5");
printf(" -------------------------------------------------------------------");
printf(" ADDITIONAL FEATURES ");
printf(" -------------------------------------------------------------------");
printf(" 1.Geyser available ");
printf(" -------------------------------------------------------------------");
printf(" NOTE :- Extra bed will cost Rs.50 per bed ");
break;
case 4:clrscr();
screenheader();
printf(" Room number >>>4 ");
printf(" Advance >>>500 ");
printf(" FEATURES OF THIS ROOM ");
printf(" -------------------------------------------------------------------");
printf(" Room Type >>> Couple ");
printf(" Room charges >>>Rs.1000 per day");
printf(" 1. Bed >>> 1");
printf(" 2.Capacity >>> 2");
printf(" -------------------------------------------------------------------");
printf(" ADDITIONAL FEATURES ");
printf(" -------------------------------------------------------------------");
printf(" 1.Geyser available");
printf(" 2.TV available ");
printf(" -------------------------------------------------------------------");
printf(" NOTE :- Extra bed will cost Rs.50 per bed ");
break;
case 5:clrscr();
screenheader();
printf(" Room number >>>5 ");
printf(" Advance >>>750 ");
printf(" FEATURES OF THIS ROOM ");
printf(" -------------------------------------------------------------------");
printf(" Room Type >>> Couple Delux ");
printf(" Room charges >>>Rs.1500 per day");
printf(" 1. Bed >>> 1");
printf(" 2.Capacity >>> 2");
printf(" -------------------------------------------------------------------");
printf(" ADDITIONAL FEATURES ");
printf(" -------------------------------------------------------------------");
printf(" 1.A/C available ");
printf(" 2.Geyser available");
printf(" 3.TV available ");
printf(" -------------------------------------------------------------------");
printf(" NOTE :- Extra bed will cost Rs.50 per bed ");
break;
}
}
void allocate()
{
clrscr();
screenheader();
getavail();
printf(" Enter the room number in which you want to stay:");
scanf("%d",&room);
if(r_avail[room-1]=='Y')
{
fflush(stdin);
printf(" Enter Name of cust living :");
gets(r_cust[room-1]);
printf(" Enter city name :");
gets(c_city[room-1]);
printf(" Enter nationality :");
gets(c_nat[room-1]);
printf(" For how many days cust want the room :");
scanf("%d",&r_per[room-1]);
printf(" Enter no. of member in your group :");
scanf("%d",&c_mem[room-1]);
if((room==1)||(room==2)||(room==3))
if((c_mem[room-1]<1)||(c_mem[room-1]>5))
{
printf(" %d members cannot be allocated this room.Allowed members are between 1-5.",c_mem[room-1]);
getch();
allocate();
}
else if((room==4)||(room==5))
if((c_mem[room-1]<1)||(c_mem[room-1]>2))
{
printf(" %d members cannot be allocated this room.Allowed members are between 1-2.",c_mem[room-1]);
getch();
allocate();
}
printf(" Enter the date of arrival :");
printf(" ------------------------------");
printf(" Year : ");
scanf("%d",&year[room-1]);
printf(" Month :");
scanf("%d",&month[room-1]);
printf(" Day :");
scanf("%d",&day[room-1]);
if((year[room-1]>9999)||(month[room-1]>12)||(month[room-1]<1)||(day[room-1]<1)||(((month[room-1]==1)||(month[room-1]==3)||(month[room-1]==5)||(month[room-1]==7)||(month[room-1]==8)||(month[room-1]==10)||(month[room-1]==12))&&(day[room-1]>31))||(((month[room-1]==4)||(month[room-1]==6)||(month[room-1]==9)||(month[room-1]==11))&&(day[room-1]>30))||((month[room-1]==2)&&((year[room-1]%400==0)||((year[room-1]%4==0)&&(year[room-1]%100!=0)))&&(day[room-1]>29))||((month[room-1]==2)&&(year[room-1]%4!=0)&&(day[room-1]>28)))
{
delay(200);
printf(" !!!!!INVALID DATE........");
getch();
allocate();
}
else
{
printf(" ... Room is allocated to ");
cputs(r_cust[room-1]);
printf(" for %d days.",r_per[room-1]);
r_avail[room-1]='N';
getch();
}
}
else
{
printf(" ERROR : Room cannot be allocated ...");
printf(" Room is not available...");
getch();
}
}
void deallocate()
{
clrscr();
screenheader();
printf(" Enter the room number:");
scanf("%d",&room);
if(r_cust[room-1]=="N.A")
{
printf(" The room is empty........");
getch();
}
else
{
printf(" Enter the name of the person staying in the room:");
fflush(stdin);
gets(name);
if(strcmpi(name,r_cust[room-1])==0)
{
printf(" Room number %d is deallocated......",room);
strcpy(r_cust[room-1],"N.A");
getch();
}
else
{
printf(" Invalid name........");
getch();
deallocate();
}
}
g_tot=(r_per[room-1]*r_charge[room-1])-advance[room-1]+tot[room-1];
printf(" Your total bill is %d",g_tot);
printf(" Thanks for staying in this hotel.........");
}
void cancel()
{
clrscr();
screenheader();
printf(" Enter the room number:");
scanf("%d",&room);
if(r_cust[room-1]=="N.A")
{
printf(" The room is empty........");
getch();
}
else
{
printf(" Enter the name of the person staying in the room:");
fflush(stdin);
gets(name);
if(strcmpi(name,r_cust[room-1])==0)
{
printf(" Reservation for room number %d is cancelled......",room);
strcpy(r_cust[room-1],"N.A");
getch();
}
else
{
printf(" Invalid name........");
getch();
cancel();
}
}
g_tot=advance[room-1];
printf(" Your total bill is %d",g_tot);
}
void putcust()
{
int j;
clrscr();
screenheader();
printf(" Enter the room number :");
scanf("%d",&room);
j=strcmp(r_cust[room-1],"N.A");
if(j==0)
{
printf(" Data not available ");
getch();
}
else
{
printf(" Room No :%d",r_no[room-1]);
printf(" Customer Name :");
cputs(r_cust[room-1]);
printf(" Period :%d",r_per[room-1]);
printf(" City :");
cputs(c_city[room-1]);
printf(" Nationality :");
cputs(c_nat[room-1]);
printf(" No of member :%d",c_mem[room-1]);
printf(" Arrival Date :%d/%d/%d",day[room-1],month[room-1],year[room-1]);
getch();
}
}
void restaurant()
{
int count=0,z=0,fc[113],answ;
char ans;
int price[113]={245,245,245,245,240,240,240,240,235,235,250,235,235,220,
215,230,215,240,250,250,250,250,250,250,250,255,245,245,245,245,250,240,
240,360,290,360,290,370,295,360,290,360,290,250,360,290,360,290,250,370,
290,360,290,250,250,280,245,290,235,265,240,290,300,256,240,265,270,255,
255,240,240,235,220,25,30,25,30,35,35,25,30,35,25,35,25,25,30,100,105,105,
100,105,100,105,125,105,105,100,105,110,115,100,100,100,105,105,105,105,
125,105,120,120,100};
char food[113][30]={"SHAHI PANEER","KADAI PANEER","CHEESE KORMA",
"MALAI KOFTA","MATAR PANEER","PALAK PANEER","MIX VEG.","ALOO GOBI",
"ALOO JEERA","CHANA MASALA","MATAR MUSHROOM","RAJMA MAKHANI","DAL MAKHANI",
"MIXED RAITA","BUNDI RAITA","PINEAPPLE RAITA","SALAD(GREEN)","DUM ALOO",
"MUSHROOM PANEER","MUTTON MASALA","MUTTON MUGHLAI","MUTTON KORMA",
"MUTTON DO PYAZA","MUTTON SAGH","MUTTON DAHI","MUTTON ROGAN JOSH",
"MUTTON CURRY","KADAI MUTTON","KEEMA LEVER","KEEMA MATAR","KEEMA EGG",
"BRAIN CURRY","EGG CURRY","BUTTER CHICKEN","BUTTER CHICKEN(1/2)",
"KADAI CHICKEN","KADAI CHICKEN(1/2)","BUTTER CHICKEN(BL)",
"BUTTER CHICKEN(BL)(1/2)","CHICKEN MUGHLAI","CHICKEN MUGHLAI(1/2)",
"CHICKEN MASALA","CHICKEN MASALA(1/2)","CHICKEN MASALA(1/4)",
"CHICKEN SAGH","CHICKEN SAGH(1/2)","CHICKEN DAHI","CHICKEN DAHI(1/2)",
"CHICKEN DAHI(1/4)","CHICKEN KORMA","CHICKEN KORMA(1/2)",
"CHICKEN DO PYAZA","CHICKEN DO PYAZA(1/2)","FISH CURRY","CHICKEN CURRY",
"CHICKEN CURRY(1/2)","CHICKEN CURRY(1/4)","CHILLI CHICKEN","TANDOORI ALOO",
"CHICKEN TIKKA","SEEKH KABAB","FISH TIKKA","CHICKEN TANDOORI",
"CHICKEN TANDOORI(1/2)","PANEER TIKKA","CHICKEN SEEKH KABAB",
"CHICKEN HARA KABAB","CHICKEN BIRYANI","MUTTON BIRYANI","PANEER PULAO",
"VEG.PULAO","JEERA RICE","STEAMED RICE","RUMALI ROTI","ROTI","NAN",
"ALOO NAN","PANEER NAN","KEEMA NAN","PARANTHA","ALOO PARANTHA",
"PANEER PARANTHA","PUDINA PARANTHA","BUTTER NAN","LACHCHA PARANTHA",
"MISSI ROTI","KHASTA ROTI","VEG.BURGER","PANEER BURGER","CHEESE SANDWICH",
"VEG.PATTI","CHICKEN PATTI","TEA","COFFEE","COLD COFFEE","PINEAPPLE",
"STRAWBERRY","CHOCOLATE","BLACK FOREST","DOUBLE STORIED","TRIPLE STORIED",
"SOFT CONE","VANILLA","STRAWBERRY","CHOCOLATE","CHOCO CHIPS","MANGO",
"TUTTI FRUITY","LICHI","PISTA BADAM","CHOCOLATE PISTA BADAM","CHOCO DIP",
"CHOCOLATE LICHI"};
clrscr();
screenheader();
printf(" *********");
printf(" MENU CARD");
printf(" *********");
printf(" VEGETARIAN");
for(i=0;i<113;count++,i++)
{
gotoxy(17,count+20);
printf("%d",i+1);
gotoxy(30,count+20);
cputs(food[i]);
gotoxy(55,count+20);
printf("%d",price[i]);
if(count==17)
{
count=0;
printf(" PRESS ANY KEY TO CONTINUE");
getch();
clrscr();
screenheader();
}
if(i==18)
{
printf(" MUTTON ");
count +=3;
}
if(i==32)
{
printf(" CHICKEN ");
count +=3;
}
if(i==57)
{
printf(" BAR-BE-QUE ");
count +=3;
}
if(i==72)
{
printf(" ROTI-NAN-PARANTHA ");
count +=3;
}
if(i==91)
{
printf(" BEVERAGES ");
count +=3;
}
if(i==100)
{
printf(" ICE-CREAMS ");
count +=3;
}
}
getch();
clrscr();
screenheader();
printf(" PRESS 0 TO GO BACK TO MENU CARD PRESS 1 TO CONTINUE ");
scanf("%d",&answ);
switch(answ)
{
case 0:restaurant();
break;
case 1 :clrscr();
do
{
printf("ENTER THE FOOD CODE YOU WANT TO HAVE :: ");
scanf("%d",&fc[z]);
z++;
puts("DO YOU WANT MORE(Y/N) ::");
fflush(stdin);
scanf("%c",&ans);
}while ((ans=='y')||(ans=='Y'));
printf(" Enter your room number:");
scanf("%d",&room);
printf(" Enter your name:");
fflush(stdin);
gets(name);
if(strcmpi(name,r_cust[room-1])!=0)
{
printf(" Wrong name...:");
getch();
restaurant();
}
getch();
clrscr();
screenheader();
for(i=0;i<z;i++)
{
cputs(food[fc[i]-1]);
printf(" %d ",price[fc[i]-1]);
tot[room-1] +=price[fc[i]-1];
}
printf("TOTAL %d",tot[room-1]);
break;
default:printf(" Wrong choice entered!!!");
getch();
restaurant();
}
}
void main()
{
char ans;
int ch;
clrscr();
screenheader();
intro();
do
{
clrscr();
screenheader();
printf(" Choose a category: ");
printf(" 1. Get availability ");
printf(" 2. Features of room ");
printf(" 3. Room allocation ");
printf(" 4. Show customer details ");
printf(" 5. Restaurant ");
printf(" 6. Cancellation ");
printf(" 7. Room Deallocation ");
printf(" 8. Exit ");
scanf("%d",&ch);
switch(ch)
{
case 1:getavail();
putavail();
break;
case 2:features();
break;
case 3:allocate();
break;
case 4:putcust();
break;
case 5:restaurant();
break;
case 6:cancel();
break;
case 7:deallocate();
break;
case 8:exit(0);
default:printf(" Wrong choice!!!! Please choose 1-6");
getch();
}
printf(" Do you want to continue:");
fflush(stdin);
scanf("%c",&ans);
}while(ans=='y'||ans=='Y');
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.