### Floors of Hotel, and 13th floor phobia

Hello fellow users,

I am posting this to mainly ask a simple question.
How can I improve the logic of dmy program.
I am suppose to make a program that is suppose to ask users about the number of floors, occupied, and the number of rooms left unoocupied by the user. This is then returned as a percemtage of occupied rooms, occupied rooms, and unoccupied room report. Thanx in advance to the ggreat users on this site!
Here is my code:

 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 #include using namespace std; double percentage; int i, rooms, totalrooms=0, occupied, totaloccupied=0; int main() { cout<<"========================================================================\n"; cout<<":::::Welcome To Hotel california, the worst hotel in the Weeest side::::\n"; cout<<"========================================================================"<<"\n\n"; int number_of_floors; cout<<"Enter the number of floors the hotel has: \n \n"; cin>>number_of_floors; for (i=1;i<=number_of_floors;i++) { if (number_of_floors == 13) { cout<<"Sorry, were triskaeidekaphobic...\n\n"; cout<<"Please Re-Enter the number of floors of the hotel has: "; cin>>number_of_floors; } if (number_of_floors < 1) { cout<<"Sorry, nothing irrational like 0 or negative values, or even characters. Thank You\n\n"; cout<<"Please Re-Enter the number of floors of the hotel has: "; cin>>number_of_floors; } cout<<"Enter the number of rooms on the "<>rooms; if (rooms<1) { while (rooms<1) { cout<<"The number of rooms should be greater then 1\n"; cout<<"Enter the number of rooms on the "<>rooms; } } totalrooms = totalrooms + rooms; cout<<"Enter the number of occupied rooms on the "<>occupied; totaloccupied = totaloccupied + occupied; } percentage = (double)totaloccupied/(double)totalrooms*100; cout<<"Report:\nTotal number of rooms in the hotel: "<

I am also wanting to avoid the 13th floor, that is why I placed a counter at the end and wanted to know also how to avoid characters like an 'A' with in my code as an imput. If anybody could check this code for some more bugs other than the obvious of imput more than twice and the code might not go back normal, than iit would be greatly appreciated.
Topic archived. No new replies allowed.