Click here to Skip to main content
15,666,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sample output

enter type of the room: 1
enter the month: Dec
enter no of days: 3
enter type of the room: 2
enter the month: Jan
enter no of days: 4
enter type of the room: 0
total amount to be paid: .......

There are only 3 type of rooms. 1, 2 and 3. if user enters any other if should appear "Invalid room type". The question says can exit by entering 0 for the room type as shown in the sample output. but in my case it says invalid room type and after shows total amount. can you please help me.

What I have tried:

#include
Posted
Updated 15-Sep-16 3:03am
v2
Comments
[no name] 15-Sep-16 8:55am    
If you do not understand your homework assignment you should be asking your teacher.
Philippe Mori 15-Sep-16 9:07am    
Where is your code. You won't learn anything if we do your whole homework!
Member 12739755 16-Sep-16 0:59am    
I have uploaded my code

C++
while(true)
   {
   // Get your value
   ...
   switch(enteredRoomType)
      {
      case 0:
         // All done - exit the app.
         exit(0);
      case 1:
      case 2:
      case 3:
         // All ok.
         break;
      default:
         cout << "Invalid room type";
         continue;
      }
   ...
   }
 
Share this answer
 
That shouldn't be nested if. That should be if chain (a sequence of if-else if statements) or, better a switch construct.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900