School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
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!



Hotel Room reservation program

Hotel Room reservation program Rate Topic: -----

#1 bugema  Icon User is offline

  • New D.I.C Head
  • Pip
  • 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

Was This Post Helpful? 0
  • +
  • -


#2 FrozenSnake  Icon User is offline

  • D.I.C Addict
  • PipPipPipPip
  • Group: Members
  • Posts: 606
  • Joined: 30-July 08


Dream Kudos: 0

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.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • PHoToN PoWeR PaCK : not included
  • Icon
  • View blog
  • Group: Moderators
  • Posts: 15,043
  • Joined: 10-May 07


Dream Kudos: 2875

Expert In: Goofing Off

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.
Was This Post Helpful? 0
  • +
  • -

#4 AndyH1963  Icon User is offline

  • D.I.C Head
  • Icon
  • Group: Members w/DIC++
  • Posts: 200
  • Joined: 22-June 08


Dream Kudos: 0

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?
Was This Post Helpful? 0
  • +
  • -

#5 bugema  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 8
  • Joined: 26-May 09


Dream Kudos: 0

Posted 27 May 2009 - 12:09 AM

View PostAndyH1963, 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.
Was This Post Helpful? 0
  • +
  • -

#6 bugema  Icon User is offline

  • New D.I.C Head
  • Pip
  • 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

Was This Post Helpful? 0
  • +
  • -

#7 bugema  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 8
  • Joined: 26-May 09


Dream Kudos: 0

Posted 28 May 2009 - 12:51 AM

View PostAndyH1963, 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

Was This Post Helpful? 0
  • +
  • -

#8 ladyinblack  Icon User is offline

  • D.I.C Regular
  • Icon
  • View blog
  • Group: Authors
  • Posts: 353
  • Joined: 08-April 09


Dream Kudos: 275

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.
Was This Post Helpful? 0
  • +
  • -

#9 deery5000  Icon User is offline

  • D.I.C Regular
  • PipPipPip
  • Group: Members
  • Posts: 380
  • Joined: 09-May 09


Dream Kudos: 0

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
Was This Post Helpful? 0
  • +
  • -

#10 JackOfAllTrades  Icon User is online

  • Mayor of Simpleton
  • Icon
  • View blog
  • Group: Moderators
  • Posts: 7,128
  • Joined: 23-August 08


Dream Kudos: 50

Expert In: Being annoyed with lazy people.

Posted 28 May 2009 - 04:29 AM

Merged duplicate topics. bugema, please do not create duplicate topics.
Was This Post Helpful? 0
  • +
  • -

#11 bugema  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 8
  • Joined: 26-May 09


Dream Kudos: 0

Posted 31 May 2009 - 01:26 AM

View Postladyinblack, 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.
Was This Post Helpful? 0
  • +
  • -

#12 bugema  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 8
  • Joined: 26-May 09


Dream Kudos: 0

Posted 01 June 2009 - 12:08 AM

View Postdeery5000, 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

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

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

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month