Note that there are some explanatory texts on larger screens.

plurals
  1. POStuck with getting the occupancy to change with the input and checking it against the capacity
    primarykey
    data
    text
    <p>Here is my problem I set this program up and the thing I need it to do I cannot figure it out. I need to make a one argument method Change_Status that changes the status of the room to the value of its argument. The method should verify that the argument value does not exceed the room capacity. If it does, the method should return -1. Here is the code that I wrote </p> <pre><code>#include "stdafx.h" #include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;string&gt; using namespace std; class HotelRoom { private: string room_no; int capacity; int occupancy; double rate; public: HotelRoom(); HotelRoom(string, int,double, int); string get_number(); int get_capacity(); int get_status(); double get_rate(); void change_rate(double); bool change_status(int); }; HotelRoom::HotelRoom (string room, int cap,double rt, int occup) { room_no = room; capacity = cap; occupancy = occup; rate = rt; } string HotelRoom::get_number() { return room_no; } int HotelRoom::get_capacity() { return capacity; } int HotelRoom::get_status() { return occupancy; } double HotelRoom::get_rate() { return rate; } void HotelRoom::change_rate( double amount) { rate += amount; } bool HotelRoom::change_status(int occupancy) { bool result; if (capacity &lt;= occupancy ) { occupancy = capacity ; result = true; } else result = false; return result; } int _tmain(int argc, _TCHAR* argv[]) { cout &lt;&lt; setprecision(2) &lt;&lt; setiosflags(ios::fixed) &lt;&lt; setiosflags(ios::showpoint); int occupancy; double amount; string room = "123"; int capacity = 4; double rate = 150.00; cout &lt;&lt; endl; cout &lt;&lt; "enter the number of guests: "; cin &gt;&gt; occupancy; HotelRoom guest ( room, capacity, rate, occupancy); cout &lt;&lt; endl; cout &lt;&lt; " Room number is " &lt;&lt; guest.get_number() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Capacity is " &lt;&lt; guest.get_capacity () &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Rate is " &lt;&lt; guest.get_rate() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Occupancy is " &lt;&lt; guest.get_status() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; endl; cout &lt;&lt; "enter the number of guests: "; cin &gt;&gt; occupancy; cout &lt;&lt; endl; cout &lt;&lt; " Room number is " &lt;&lt; guest.get_number() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Capacity is " &lt;&lt; guest.get_capacity() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Rate is " &lt;&lt; guest.get_rate() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Occupancy is " &lt;&lt; guest.get_status() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; endl; cout &lt;&lt; " Change room rate: "; cin &gt;&gt; amount; guest.change_rate(amount); cout &lt;&lt; endl; cout &lt;&lt; " Room number is " &lt;&lt; guest.get_number() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Capacity is " &lt;&lt; guest.get_capacity() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Rate is " &lt;&lt; amount &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Occupancy is " &lt;&lt; guest.get_status() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; endl; cout &lt;&lt; "enter the number of guests: "; cin &gt;&gt; occupancy; cout &lt;&lt; endl; cout &lt;&lt; " Room number is " &lt;&lt; guest.get_number() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Capacity is " &lt;&lt; guest.get_capacity() &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Rate is " &lt;&lt; amount &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; " Room Occupancy is " &lt;&lt; guest.get_status() &lt;&lt; endl &lt;&lt; endl; system("pause"); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload