Please do this following program in the c language Create a
Please do this following program in the c language:
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.
Solution
main()
{
int rno,choice;
clrscr();
do{
printf(\"The room numbers 20, 30, 40, and 50 are vacant:);
printf(\"Enter your choice of room number\");
scanf(\"%d\",rno);
if(rno==20)
{
printf(\"Room no:20\ \");
printf(\"Enter the choice of entry by user:\ 1. Room rate\ 2.smoking/non smoking \ 3. customer id \ 4.no.of days reserved\ \");
printf(\"Enter your choice\");
scanf(\"%d\",&choice);
switch(choice)
{
case 1: int rrate;
scanf(\"%d\",&rrate);
printf(\"Room rate:%d\",rrate);
break;
case 2: //same as above;1 for smoking, 0 for non-smoking.
case 3: //enter customer id
case 4: //enter no.of days reserved.
default: printf(\"Wrong entry\");
break;
}}
else if(rno=30)
{
printf(\"Room no:30\ \");
printf(\"Enter the choice of entry by user:\ 1. Room rate\ 2.smoking/non smoking \ 3. customer id \ 4.no.of days reserved\ \");
printf(\"Enter your choice\");
scanf(\"%d\",&choice);
switch(choice)
{
case 1: int rrate;
scanf(\"%d\",&rrate);
printf(\"Room rate:%d\",rrate);
break;
case 2: //same as above;1 for smoking, 0 for non-smoking.
case 3: //enter customer id
case 4: //enter no.of days reserved.
default: printf(\"Wrong entry\");
break;
}}
else if(rrno==40)
{
printf(\"Room no:40\ \");
printf(\"Enter the choice of entry by user:\ 1. Room rate\ 2.smoking/non smoking \ 3. customer id \ 4.no.of days reserved\ \");
printf(\"Enter your choice\");
scanf(\"%d\",&choice);
switch(choice)
{
case 1: int rrate;
scanf(\"%d\",&rrate);
printf(\"Room rate:%d\",rrate);
break;
case 2: //same as above;1 for smoking, 0 for non-smoking.
case 3: //enter customer id
case 4: //enter no.of days reserved.
default: printf(\"Wrong entry\");
break;
}}
else if(rrno==50)
{
printf(\"Room no:20\ \");
printf(\"Enter the choice of entry by user:\ 1. Room rate\ 2.smoking/non smoking \ 3. customer id \ 4.no.of days reserved\ \");
printf(\"Enter your choice\");
scanf(\"%d\",&choice);
switch(choice)
{
case 1: int rrate;
scanf(\"%d\",rrate);
printf(\"Room rate:%d\",rrate);
break;
case 2: //same as above;1 for smoking, 0 for non-smoking.
case 3: //enter customer id
case 4: //enter no.of days reserved.
default: printf(\"Wrong entry\");
break;
}}
else { printf(\"Wrong entry of room number\ \");}
printf(\"Continue 1 /exit 0\")
scanf(\"%d\",&b);
}while(b==1);
getch();
}