C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 306,825 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,752 people online right now. Registration is fast and FREE... Join Now!




Hotel Room reservation program

 

Hotel Room reservation program

bugema

26 May, 2009 - 11:31 PM
Post #1

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 8

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

User is offlineProfile CardPM
+Quote Post


FrozenSnake

RE: Hotel Room Reservation Program

26 May, 2009 - 11:35 PM
Post #2

D.I.C Regular
***

Joined: 30 Jul, 2008
Posts: 483



Thanked: 30 times
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

no2pencil

RE: Hotel Room Reservation Program

26 May, 2009 - 11:35 PM
Post #3

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,488



Thanked: 303 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
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.
User is offlineProfile CardPM
+Quote Post

AndyH1963

RE: Hotel Room Reservation Program

26 May, 2009 - 11:35 PM
Post #4

D.I.C Head
Group Icon

Joined: 22 Jun, 2008
Posts: 197



Thanked: 21 times
My Contributions
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?
User is offlineProfile CardPM
+Quote Post

bugema

RE: Hotel Room Reservation Program

27 May, 2009 - 12:09 AM
Post #5

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 8

QUOTE(AndyH1963 @ 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?


thanks for your fast reply. I'm gonna post the code.
User is offlineProfile CardPM
+Quote Post

bugema

RE: Hotel Room Reservation Program

28 May, 2009 - 12:48 AM
Post #6

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 8

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.

cpp
#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
User is offlineProfile CardPM
+Quote Post

bugema

RE: Hotel Room Reservation Program

28 May, 2009 - 12:51 AM
Post #7

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 8

QUOTE(AndyH1963 @ 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?


Here is part of code:

cpp
#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
User is offlineProfile CardPM
+Quote Post

ladyinblack

RE: Hotel Room Reservation Program

28 May, 2009 - 02:28 AM
Post #8

D.I.C Regular
Group Icon

Joined: 8 Apr, 2009
Posts: 323



Thanked: 7 times
Dream Kudos: 25
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

deery5000

RE: Hotel Room Reservation Program

28 May, 2009 - 03:24 AM
Post #9

D.I.C Regular
***

Joined: 9 May, 2009
Posts: 361



Thanked: 20 times
My Contributions

CODE

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

CODE

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
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades

RE: Hotel Room Reservation Program

28 May, 2009 - 04:29 AM
Post #10

I exist to Google your problems.
Group Icon

Joined: 23 Aug, 2008
Posts: 5,311



Thanked: 453 times
Dream Kudos: 50
Expert In: Being annoyed with lazy people.

My Contributions
Merged duplicate topics. bugema, please do not create duplicate topics.
User is offlineProfile CardPM
+Quote Post

bugema

RE: Hotel Room Reservation Program

31 May, 2009 - 01:26 AM
Post #11

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 8

QUOTE(ladyinblack @ 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.



Thanks for advice. I appreciate your support.
User is offlineProfile CardPM
+Quote Post

bugema

RE: Hotel Room Reservation Program

1 Jun, 2009 - 12:08 AM
Post #12

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 8

QUOTE(deery5000 @ 28 May, 2009 - 03:24 AM) *

CODE

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

CODE

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()?

CODE


#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: 1 Jun, 2009 - 12:19 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/20/09 10:37PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month