Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you need to implement a c program that manages rooms in a small hotel that has 5 single rooms (no kids allowed), 10 double rooms

you need to implement a c program that manages rooms in a small hotel that has 5 single rooms (no kids allowed), 10 double rooms (a max of 1 kid is allowed) and 3 studio rooms (a max of 3 kids allowed).

The price for a single room is 350 MAD

o Single rooms are numbered oddly from 1 to 9

The price of a double room 500 MAD

o Double rooms are numbered evenly from 2 to 20

The price of a studio room 700 MAD

o Studio rooms numbered 33, 44, 55 respectively

An extra 50 MAD is applied for every kid

Important points you need to consider during the implementation:

o The files that you will used in this project are for output only the rest of the operations should be carried in the arrays corresponding to room type (you need to use three arrays)

Except for Hotel earning

o You need to use three structures for every room type:

Single room: status(F if Full E if Empty), check in date(DD-MM- YYYY), name of the client, identity number(CIN), room number, and number of night to spend

Double room: status(F if Full E if Empty),check in date, name of the client1, name of client 2, client 1 identity number(CIN), client 2 identity number, room number, status_kid (1 if accompanied with a kid 0 otherwise), and number of night to spend

Studio room: status(F if Full E if Empty), check in date, name of the client1, name of client 2, client 1 identity number(CIN), client 2 identity number, room number, number of kids and the number of night to spend

o Your program should display the following menu with every option implemented with a user defined function (except for quit). Please note that you must respect the concept of input/output argument and local variables

1. Checkavailabilityofaroomtype

2. Checkin

3. Checkout

4. HotelEarning

5. Quit

- Initially you start your code with setting all rooms status to empty and every room must have its assigned room number

- Check in is used to book a room (if available) for a person. Besides from check in, the hotel manager would like to keep a record of people visited the hotel so for every person checked in you need to add the needed information to a text file called history.txt (input chosen are just examples):

Client Name: Hannah Sanders Partner: None

Room type: Single

Number of kids:

0

Number of nights:

2 ------------------------------------------------

- Check out is used to produce the bill for a particular client in the form of a text file

o The txt file produced will be named Client_Name_CIN (ex Hanaa_Talei_A123456.txt) and must contain the following information :

Check in Date:

Client Name:

Room Type:

Number of kids: Number of nights: Total to pay:

Thanks for your visit!

o Remember to free the room!

- Check availability is used to print available rooms for a particular

room type

- Hotel Earning will have access to history.txt and print on screen

the hotel earning in MAD.

- You may use extra user defined functions if needed

- You need to handle possible errors. Example:

o You try to do check out for a person not in the hotel!

o Check in for a room category while no room is available o .......

the problem statement is complete and doesn't have any lacking information, here is a code for this problem, only it contains a lot of issues when you try to run the menu (go through it all to see) and the file history.txt is not used as asked.

#include #include struct single_room { int room_no; char status; long int checkindate; char*name; int cin; int roomno; int no_night; }; struct double_room { int room_no; char status; long int checkindate; char*name1; char*name2; int cin1,cin2; int kid_status; int no_night; }; struct studio_room { int room_no; char status; long int checkindate; char*name1; char*name2; int cin1,cin2; int no_kids; int no_night; }; void CheckAvailabilityOfRoom(struct single_room*arr,struct double_room*brr,struct studio_room*crr) { int choice,flag=0; system("CLS"); printf("1. Single Room 2. Double Room 3. Studio Room Enter your Choice(1-3)"); scanf("%d",&choice); if(choice==1) { printf("Vacant Single Room No. are: "); for(int i=0;i<5;i++) { if(arr[i].status=='E') { flag++; printf("%d ",arr[i].room_no); } } if(flag==0) printf("No Single room is vacant "); } flag=0; if(choice==2) { printf("Vacant Single Room No. are: "); for(int i=0;i<10;i++) { if(brr[i].status=='E') { flag++; printf("%d ",brr[i].room_no); } } if(flag==0) printf("No Single room is vacant "); } if(choice==3) { printf("Vacant Single Room No. are: "); for(int i=0;i<3;i++) { if(crr[i].status=='E') { flag++; printf("%d ",crr[i].room_no); } } if(flag==0) printf("No Single room is vacant "); } } void CheckIn(struct single_room*arr,struct double_room*brr,struct studio_room*crr,int HotelEarning[]) { int choice,cin; char*name; long int date; system("CLS"); printf("1. Single Room 2. Double Room 3. Studio Room Enter your Choice(1-3)"); scanf("%d",&choice); if(choice==1) { for(int i=0;i<5;i++) { if(arr[i].status=='E') { arr[i].status='F'; printf(" Enter Name "); scanf("%s",arr[i].name); printf(" Enter Date "); scanf("%lld",&arr[i].checkindate); printf(" Enter CIN "); scanf("%d",&arr[i].cin); printf(" Enter No.of Nights "); scanf("%d",&arr[i].no_night); HotelEarning[0]+=arr[i].no_night*350; break; } } } if(choice==2) { for(int i=0;i<10;i++) { if(brr[i].status=='E') { brr[i].status='F'; printf(" Enter Name 1 "); scanf("%s",brr[i].name1); printf(" Enter Name 2 "); scanf("%s",brr[i].name2); printf(" Enter Date "); scanf("%lld",&brr[i].checkindate); printf(" Enter CIN 1 "); scanf("%d",&brr[i].cin1); printf(" Enter CIN 2 "); scanf("%d",&brr[i].cin2); printf(" Enter Kid status(0/1)"); scanf("%d",&brr[i].kid_status); printf(" Enter No.of Nights "); scanf("%d",&brr[i].no_night); HotelEarning[0]+=brr[i].no_night*500; break; } } } if(choice==3) { for(int i=0;i<3;i++) { if(crr[i].status=='E') { crr[i].status='F'; printf(" Enter Name 1"); scanf("%s",crr[i].name1); printf(" Enter Name 2"); scanf("%s",crr[i].name2); printf(" Enter Date "); scanf("%lld",&crr[i].checkindate); printf(" Enter CIN 1 "); scanf("%d",&crr[i].cin1); printf(" Enter CIN 2 "); scanf("%d",&crr[i].cin2); printf(" Enter Kids No."); scanf("%d",&crr[i].no_kids); printf(" Enter No.of Nights "); scanf("%d",&crr[i].no_night); HotelEarning[0]+=crr[i].no_night*750; break; } } } } void CheckOut(struct single_room*arr,struct double_room*brr,struct studio_room*crr,int roomno) { if(roomno==33||roomno==44||roomno==55) { for(int i=0;i<3;i++) { if(crr[i].room_no==roomno) { crr[i].status='E'; break; } } } else if(roomno%2==0) { for(int i=0;i<10;i++) { if(brr[i].room_no==roomno) { brr[i].status='E'; break; } } } else { for(int i=0;i<5;i++) { if(arr[i].room_no==roomno) { arr[i].status='E'; break; } } } } int main() { struct single_room arr[5]; struct double_room brr[10]; struct studio_room crr[3]; int roomno; char ex; int HotelEarning[1]={0}; for(int i=0;i<5;i++) { arr[i].room_no=2*i+1; arr[i].status='E'; } for(int i=0;i<10;i++) { brr[i].room_no=(2*i+2); brr[i].status='E'; } for(int i=0;i<3;i++) crr[i].status='E'; crr[0].room_no=33; crr[1].room_no=44; crr[2].room_no=55; b:printf("1. Check availability of a room type 2. Check In "); printf("3. Check Out 4. Hotel Earning 5. Quit "); printf(" Enter your Choice:(1-5)"); int choice; while(choice!=5) { scanf("%d",&choice); if(choice==1) { CheckAvailabilityOfRoom(arr,brr,crr); printf(" "); goto b; } if(choice==2) { CheckIn(arr,brr,crr,HotelEarning); printf(" Room has been alloted to you!! "); goto b; } if(choice==3) { printf("Enter room number to proceed check Out"); scanf("%d",&roomno); CheckOut(arr,brr,crr,roomno); system("CLS"); goto b; } if(choice==4) { printf(" ********Hotel Earning is: %d MAD********* ",HotelEarning[0]); goto b;

} } }

like what? everything is there

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions