Think about normal loops ie:
Code:
#include <iostream>
int main()
{
unsigned int no_floors=0, no_rooms=0, no_op_rooms=0, temp=0;
while(no_floors < 1)
{
std::cout << "Enter number of floors in building: ";
std::cin >> no_floors;
if(no_floors < 1)
std::cout << "Error please enter 1 (ONE) or more floors" << std::endl;
}
for(int i=1; i <= no_floors; ++i)
{
if(i == 13)
continue; /* skip 13th floor */
/* bad programming style to use gotos
* but if we know what we're doing....
*/
start_over:
std::cout << "Enter number of rooms on " << i << ". floor: ";
std::cin >> temp;
if(temp < 10)
{
std::cout << "Error you should give 10 or more rooms pr. floor" << std::endl;
goto start_over;
}
no_rooms += temp;
std::cout << "Enter number of occupied rooms on " << i << ". floor: ";
std::cin >> temp;
/* figuring out a way to check for more occupied rooms
* than the floor has, is left as a user implementation
*/
no_op_rooms += temp;
}
std::cout << "The calculation is the users implementation" << std::endl;
return 0;
}
This is just written directly into the composer here, and has not been tested/compiled/anything, if it will work, only god knows.. An even he might be wrong.
If you were to create a combination where it should portrait the number of rooms and occupied rooms pr. floors, then you should use the
std::vector type for your no_rooms and no_op_rooms, where every instance in those vectors represents the floors.