Hi im new, and I bring you my woes for you to comfort me and brighten my day!
The only errors I get when compiling my program are:
pgm4b.cpp: In function 'int main()':
pgm4b.cpp:43: error: expected primary-expression before 'else'
pgm4b.cpp:43: error: expected `;' before 'else'
And I know that the "expected ';' before 'else'" usually has to do with the ill-placement of an ';' after an if() condition before the commands, but nothing as such exists in my code, or atleast any I can find.
The program is supposed to take in user input variables for a hotel
What is the top floor?
then a loop is started and repeats this questions in correlation to the # of floors
how many rooms on that floor?
how many are occupied
Then the program should calculate
How many rooms the hotel has
how many are occupied
how many are empty
and the occupancy % of filled to empty rooms
and the program should skip processing of floor six as the hotel doesn't a floor six or something,
ALSO determine the heart Break floor which is the floor with the least amount of occupied rooms.
I've tried just removing the else at line 43, and it compiles fine, but when I run it my occRate and heartBreakF and heartBreakO return as 0.Code:// pgm4b.cpp Kyle o'Brien cs201 1:30 #include <iostream> #include <iomanip> using namespace std; int main() { // opening block for main int tFloor, fRooms, oRooms; int tfRooms = 0; int toRooms = 0; int heartBreakF = 0; int heartBreakO = 0; int floor = 1; int empty; double occRate; cout << "What is the top floor? " << endl; cin >> tFloor; if (tFloor >= 1) { // validation while(floor <= tFloor) { // floor is acting counter if (floor == 6) // skipping floor 6 floor++; else // skipping floor 6 cout << "How many rooms on floor " << floor << " ?"; cout << endl; cin >> fRooms; cout << "How many of those are occupied? " << endl; cin >> oRooms; if(oRooms < oRooms) { // HeartBreak Checker heartBreakO = oRooms; heartBreakF = floor; } tfRooms = tfRooms + fRooms; toRooms = toRooms + oRooms; floor++; } // loop closing else // validation else option cout << "Enter a higher value for top Floor" << endl; } // validation closing occRate = toRooms / tfRooms; empty = tfRooms - toRooms; cout << fixed; cout << "The hotel has a total of " << tfRooms << " rooms"; cout << endl; cout << toRooms << " are occupied" << endl; cout << empty << " are empty" << endl; cout << "The occupancy rate is " << setprecision(1) << occRate << "%" << endl; cout << "The heartbreak floor is: " << heartBreakF << " with only "; cout << heartBreakO << " occupied rooms." << endl; return 0; }
Thanks again in advance!


. I can tell you are trying to indent, but your way is certainly not common, and even worse, it's inconsistent.
