Hello, I am trying to do a program that involves loops and a nested if.
The user needs to input a hotel specification, and if it meets the criteria to ask further questions regarding.
If the user enters the incorrect number, it goes back to the previous question and asks it again.
In this specific problem, the user will enter the location of the hotel.
Then they will enter the amount of levels the hotel has, which needs to be between 1 and 5.
Then they will enter the amount of rooms that are occupied for single, double, king and suites.
The questions about occupied rooms will go from 1 to the amount of levels the user said the hotel has, in a loop until complete.
The problem I am having is that the only question that is being asked is about the Single rooms, the first if on the program below.
Can anyone point me to what am I doing wrong?
using namespace std;
int main()
{
// Constants for hotel
const int single_room = 60;
const int double_room = 75;
const int king_room = 100;
const int suite_room = 150;
int min_floors = 1;
const int max_floors = 5;
const int min_rooms = 1;
const int max_rooms = 30;
int number_floors;
int single_rooms;
int double_rooms;
int king_rooms;
int suite_rooms;
//variables with user input
int total_floors;
string location;
cout << "==================================" << endl;
cout << " Hotel" << endl;
cout << "==================================" << endl;
cout << "\nEnter the location of this hotel chain : ";
cin >> location;
do {
cout << "\nEnter total number of floors of the hotel : ";
cin >> number_floors;
if (number_floors < min_floors || number_floors > max_floors)
{
cout << "\nNumber of floors should be between 1 and 5! Please, try again.\n";
}
else
{
do {
if (number_floors > min_floors || number_floors < max_floors)
{
cout << "\nHow many SINGLE rooms are occupied in the " << min_floors << "th floor: ";
cin >> single_rooms;
}
else if (single_rooms < min_rooms || single_rooms > max_rooms)
{
cout << "\nNumbers of rooms should be between 1 and 30! Please, try again.";
}
else if (single_rooms > min_rooms || single_rooms < max_rooms)
{
cout << "\nHow many DOUBLE rooms are occupied in the " << min_floors << "th floor: ";
cin >> double_rooms;
}
else if (double_rooms < min_rooms || double_rooms > max_rooms)
{
cout << "\nNumbers of rooms should be between 1 and 30! Please, try again.";
}
else if (double_rooms > min_rooms || double_rooms < max_rooms)
{
cout << "\nHow many KING rooms are occupied in the " << min_floors << "th floor: ";
cin >> king_rooms;
}
else if (king_rooms < min_rooms || king_rooms > max_rooms)
{
cout << "\nNumbers of rooms should be between 1 and 30! Please, try again.";
}
else if (king_rooms > min_rooms || king_rooms < max_rooms)
{
cout << "\nHow many SUITE rooms are occupied in the " << min_floors << "th floor: ";
cin >> suite_rooms;
}
else if (suite_rooms < min_rooms || suite_rooms > max_rooms)
{
cout << "\nNumbers of rooms should be between 1 and 30! Please, try again.";
}