How to write this?

I wanted some guidance in doing the hotel management program.

Here it is

{
clrscr();
int r,flag;
ofstream fout("Record.dat",ios::app);

cout<<"\n Enter Customer Detalis";
cout<<"\n ----------------------";
cout<<"\n\n Seat No.: ";
cin>>r;
flag=check(r);

if(flag)
cout<<"\n Sorry..!!!Room is already booked";

else
{
room_no=r;
cout<<" Name: ";
gets(name);
cout<<" Address: ";
gets(address);
cout<<" Phone No: ";
gets(phone);
fout.write((char*)this,sizeof(hotel));
cout<<"\n Room is booked...!!!";
}

cout<<"\n Press any key to continue.....!!";
getch();
fout.close();
}

I want to make room numbers with letters
Eg: Example room no. 12A,12B,12C
How do I do it?
If possible can you please edit it in the above given program it self.?
Any help will be greatly appreciated.

Also, how can I include class of travel?
I mean economy,business or first?
Last edited on
your room number is stored in "r" so this will need to be a string to store "12D" for example.

1
2
3
#include<string>

std::string r;


so will room_no, so your class can store the input.

in order to store travel class, you will need another string input similar to seat number, and your class will also need a string variable to hold the input, same as room_no,name,addres,etc...
> I want to make room numbers with letters
> Example room no. 12A,12B,12C

If it is always a number followed by a letter, it would be easier (for validation etc.) to store the room number as a pair of int and char.

Perhaps: using room_number_t = std::pair<int,char> ;

http://en.cppreference.com/w/cpp/utility/pair
Also, how can I include class of travel?
I mean economy,business or first?

I'm confused. You prompt for a seat number, then display "The room is booked".
Is this for a hotel or airplane?

If this is for an airplane, you could do the following:
1
2
3
4
5
 
int row;
char seat;
cout << "Enter row number and seat letter (separated by a space)";
cin >> row >> seat;


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.



Last edited on
Jaybob66 (28)
Thx a lot for ur help!
God bless!!

JLBorges (2727)
Thx a lot for ur help!
ur idea is worth pondering!!
God bless!!

AbstractionAnon (1106)
Yes it is for an airplane booking.
Yes I will make use of code tags next tym!!
Thx a lot for ur help!
God bless!!

Topic archived. No new replies allowed.