I am trying to compile this program, but am having some difficulty. Can someone please have a look at my code and tell me what I'm missing, or if anything seems out of place? Much appreciated.
------------------------------------------
Problem: Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has. A loop should then iterate once for each floor. In each iteration, the loop should ask the user for the number of rooms on the floor and how many of them are occupied. After all the iterations, the program should display how many rooms the hotel has, how many of them are occupied, how many are unoccupied, and the percentage of rooms that are occupied. The percentage may be calculated by dividing the number of rooms occupied by the number of rooms.
NOTE: It is traditional that most hotels do not have a thirteenth floor. The loop in this program should skip the entire thirteenth iteration.
Input Validation: Do not accept a value less than one for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor.
ALGORITHM:
1. Get number of floor
2. Get number of rooms from each floor
3. Add number of rooms from individual floor to total number of rooms the hotel has
4. Get number of rooms occupied from each floor
5. Add number of rooms occupied from each floor to total number of rooms occupied the hotel has
6. Calculate the occupancy rate
7. Display output
-----------------------------------
My code thus far:
#include <iostream>
#include "stdafx.h"
using namespace std;
int main ()
{
int numFloors=0, //store number of floors in hotel
numRooms=0, //store number of rooms in each floor
numOccupied=0, //store number of rooms occupied in each floor
totRooms = 0, //store total of rooms in hotel
totOccupied = 0, //store total of occupied rooms in hotel
totUnoccupied=0; //store total of unoccupied rooms in hotel
double occupRate=0.0; //store hotel occupancy rate
cout << "How many floors are in the hotel?\n"; //Prompt user for number of floors
cin >> numFloors
cout << "How many rooms are in the #" << floor << " floor?\n"; //Prompt user for number of rooms
cin >> numRooms;
totRooms += numRooms; //number of rooms in each floor will be added to totRooms
cout << "How many rooms are occupied?\n"; //Prompt user for number of rooms occupied
cin >> numOccupied;
totOccupied += numOccupied; //number of rooms occupied in each floor will be added to totOccupied
totUnoccupied = totRooms - totOccupied; //store total of unoccupied rooms in hotel
occupRate= static_cast<double>(totOccupied) / totRooms; //store occupancy rate
cout << "\n\nThe hotel has " << totRooms << " rooms.\n";
cout << totOccupied << " rooms are occupied.\n";
cout << totUnoccupied << " rooms are unoccupied.\n";
cout << fixed << showpoint << setprecision(1);
cout << occupRate*100 << "% of the rooms are occupied.\n\n"; //display occupancy rate in percentage format