What's Here?
- Members: 340,125
- Replies: 920,439
- Topics: 154,931
- Snippets: 4,855
- Tutorials: 1,257
- Total Online: 4,046
- Members: 119
- Guests: 3,927
|
Welcome to Dream.In.Code |
|
|
Become an Expert!
Join 340,125 Programmers for FREE! Get instant access to thousands  of experts, tutorials, code snippets, and more! There are 4,046 people online right now. Registration is fast and FREE... Join Now!
Chat LIVE With a Expert
|
Hotel Room reservation program
Hotel Room reservation program
Rate Topic:
   

- New D.I.C Head
-
-
Group:
New Members
-
Posts:
8
-
Joined:
26-May 09
Dream Kudos: 0
Posted 26 May 2009 - 11:31 PM
I need your collective support to solve this problem. I don't know even how to beginn. Thanks.
Declare a class HotelRoom. The class has the following private data members: the room number(an interger), the room capacity(an interger representing the maximum number of people the room can accommodate) , the occupancy status ( an interger,0 if the room is not occupied, otherwise the number of occupants, in the room), and the daily rate( a double), The member functions include the following: a three argument function intRoom() that sets the room number to its first argument, the room capacity to the second argument, the room rate to the third argument, and the room capacity status to 0; an accessor function for each data member of the class (Get-Number(), Get-Capacity(), Get-Status(), and Get-Rate()); and a one-argument function Change-Status() that changes the occupancy status of the room to the value of its argument. The function should verify that the argument values does not exceed the room capacity. If it does the function should return –1; and a one argument function Change-Rate() that sets the room rate to the value of its argument.
Write a main() that creates a hotel room with room number 123, with capacity of 4, and rate of 150.00. Suppose a person checks in. The program should ask the user to enter the number of guests to occupy the room. Change the status of the room to reflect the number of guests that just checked in. Display the information about the room in a nice format. Now assume that the guests check out. Change the room rate to 175.00. Finally assume that another person checks in. Ask the user to enter the number of guests to occupy the room. Change the room’s status accordingly and display the information about the room.
This post has been edited by no2pencil: 26 May 2009 - 11:45 PM
Posted 26 May 2009 - 11:35 PM
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well. Please post like this:  Thank you for helping us helping you.
Posted 26 May 2009 - 11:35 PM
Please, only use the code tags when you are actually posting code.
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well. Please post like this:  Thank you for helping us helping you.
Posted 26 May 2009 - 11:35 PM
Write the code and if you have any particular problem with it, post your code (or a portion thereof) and specify the problem you are having etc...
Seems quite a straightforward question so whats the problem?

- New D.I.C Head
-
-
Group:
New Members
-
Posts:
8
-
Joined:
26-May 09
Dream Kudos: 0
Posted 27 May 2009 - 12:09 AM
AndyH1963, on 26 May, 2009 - 11:35 PM, said:
Write the code and if you have any particular problem with it, post your code (or a portion thereof) and specify the problem you are having etc...
Seems quite a straightforward question so whats the problem?
thanks for your fast reply. I'm gonna post the code.

- New D.I.C Head
-
-
Group:
New Members
-
Posts:
8
-
Joined:
26-May 09
Dream Kudos: 0
Posted 28 May 2009 - 12:48 AM
My problem is how to get to the end. I pose the question again. Declare a class HotelRoom. The class has the following private data members: the room number(an interger), the room capacity(an interger representing the maximum number of people the room can accommodate) , the occupancy status ( an interger,0 if the room is not occupied, otherwise the number of occupants, in the room), and the daily rate( a double), The member functions include the following: a three argument function intRoom() that sets the room number to its first argument, the room capacity to the second argument, the room rate to the third argument, and the room capacity status to 0; an accessor function for each data member of the class (Get-Number(), Get-Capacity(), Get-Status(), and Get-Rate()); and a one-argument function Change-Status() that changes the occupancy status of the room to the value of its argument. The function should verify that the argument values does not exceed the room capacity. If it does the function should return –1; and a one argument function Change-Rate() that sets the room rate to the value of its argument.
#include <ionstream.p>
#include <iomanip.h>
class HotelRoom
{
private:
room number(int);
room capacity(int);
occupancy status(int);
daily rate(double);
public:
int room( int,int,double);
int Get-Number();
int Get-Capacity();
int Get-Status();
double Get-Rate();
int Change-Status();
};
int main()
{
}
*** MOD EDIT: Fixed tags. Only put code into code tags, not text. ***
This post has been edited by JackOfAllTrades: 28 May 2009 - 04:30 AM

- New D.I.C Head
-
-
Group:
New Members
-
Posts:
8
-
Joined:
26-May 09
Dream Kudos: 0
Posted 28 May 2009 - 12:51 AM
AndyH1963, on 26 May, 2009 - 11:35 PM, said:
Write the code and if you have any particular problem with it, post your code (or a portion thereof) and specify the problem you are having etc...
Seems quite a straightforward question so whats the problem?
Here is part of code:
#include <ionstream.h>
#include <iomanip.h>
class HotelRoom
{
private:
room number(int);
room capacity(int);
occupancy status(int);
daily rate(double);
public:
int room( int,int,double);
int Get-Number();
int Get-Capacity();
int Get-Status();
double Get-Rate();
int Change-Status();
};
int main()
{
}
This post has been edited by JackOfAllTrades: 28 May 2009 - 04:23 AM
Posted 28 May 2009 - 02:28 AM
Hi,
Were'nt you supposed to have declared your methods with some void or int or whatever. And I don't think you were supposed to leave spaces inbetween your declared variables.
Seems you new to programming, or probably don't know how to continue with inheritance and classes. Have a look at some of our tutorials, it is definitely most helpful, there are some info on classes and inheritance and declaration within methods. Also, your question, break up the question into individual items so you do one thing at a time.
Posted 28 May 2009 - 03:24 AM
class HotelRoom
{
private:
int _roomNumber;
int _roomCapacity;
int _occupancyStatus;
double _dailyRate;
public:
HotelRoom();
~HotelRoom();
void setRoomNumber(int roomNum);
int getRoomNumber();
// add the rest to here
};
Create a new class, HotelRoom.h and add these files.
you should add functions to set and get the variable names
in HotelRoom.cpp use this method
void HotelRoom::setRoomNumber(int roomNum)
{
_roomNumber = roomNum;
}
int HotelRoom::getRoomNumber()
{
return _roomNumber;
}
// add the rest to here
im guessing you have an understanding of fuctions because your now dealing with classes? am i correct
in saying that?
when calling a class from main
you simply use
HotelRoom some name;
somename.setRoomNumber( pass in variable here eg roomNumber )
Hope this helps
Kevin
Posted 28 May 2009 - 04:29 AM
Merged duplicate topics. bugema, please do not create duplicate topics.

- New D.I.C Head
-
-
Group:
New Members
-
Posts:
8
-
Joined:
26-May 09
Dream Kudos: 0
Posted 31 May 2009 - 01:26 AM
ladyinblack, on 28 May, 2009 - 02:28 AM, said:
Hi,
Were'nt you supposed to have declared your methods with some void or int or whatever. And I don't think you were supposed to leave spaces inbetween your declared variables.
Seems you new to programming, or probably don't know how to continue with inheritance and classes. Have a look at some of our tutorials, it is definitely most helpful, there are some info on classes and inheritance and declaration within methods. Also, your question, break up the question into individual items so you do one thing at a time.
Thanks for advice. I appreciate your support.

- New D.I.C Head
-
-
Group:
New Members
-
Posts:
8
-
Joined:
26-May 09
Dream Kudos: 0
Posted 01 June 2009 - 12:08 AM
deery5000, on 28 May, 2009 - 03:24 AM, said:
class HotelRoom
{
private:
int _roomNumber;
int _roomCapacity;
int _occupancyStatus;
double _dailyRate;
public:
HotelRoom();
~HotelRoom();
void setRoomNumber(int roomNum);
int getRoomNumber();
// add the rest to here
};
Create a new class, HotelRoom.h and add these files.
you should add functions to set and get the variable names
in HotelRoom.cpp use this method
void HotelRoom::setRoomNumber(int roomNum)
{
_roomNumber = roomNum;
}
int HotelRoom::getRoomNumber()
{
return _roomNumber;
}
// add the rest to here
im guessing you have an understanding of fuctions because your now dealing with classes? am i correct
in saying that?
when calling a class from main
you simply use
HotelRoom some name;
somename.setRoomNumber( pass in variable here eg roomNumber )
Hope this helps
Kevin
Am almost there. My programing is getting better. Now how do i get further from the main()?
#include <iostream.h>
#include <iomanip.h>
class HotelRoom
{
private:
int _roomNumber;
int _roomCapacity;
int _occupancyStatus;
double _dailyRate;
public:
HotelRoom();
~HotelRoom();
void setRoomNumber(int roomNum);
int getRoomNumber();
int setRoomCapacity(int roomCap);
int getRoomCapacity();
int setoccupancyStatus(int occupStatus);
int getoccupancyStatus();
double setdailyRate(double dRate);
double getdailyRate();
void initRoom(int roomNum,int roomCap, double roomRate, occupStatus = 0);
int ChangeStatus(int occupStatus);
double ChangeRate(double roomRate);
};
void HotelRoom::setRoomNumber(int roomNum)
{
_roomNumber = roomNum;
}
int HotelRoom::getRoomNumber()
{
return _roomNumber;
}
int HotelRoom::setRoomCapacity(int roomCap)
{
_roomCapacity = roomCap;
}
int HotelRoom::getRoomCapacity()
{
return _roomCapacity;
}
int HotelRoom::setoccupancyStatus(int occupStatus)
{
_occupancyStatus = occupStatus;
}
int HotelRoom::getoccupancyStatus()
{
return _occupancyStatus;
}
double HotelRoom::setdailyRate(double dRate)
{
_dailyRate = dRate;
}
double HotelRoom::getdailyRate()
{
return _dailyRate;
}
int main()
{
int roomNum;
roomNum = 123;
int roomCap;
roomCap = 4;
double roomRate;
roomRate = 150.00;
int i; //number of guests.
cout<<"\nEnter number of guests:"<<endl;
cin>> i;
// i need some help to get further from here
return 0;
}
This post has been edited by bugema: 01 June 2009 - 12:19 AM
1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users
|
Be Social
Programming
Web Development
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|