New here, but i cant seem to fix this code.
Very new to C++ if someone could help me out here that would be great.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#include <iostream>
#include <iomanip>
using namespace std;
//Function prototypes
int getfloors();
int getempty(int occ, int totalrooms);
int getrooms(int occ);
int getocc();
int getocc(int rooms);
double getoccrate(int totalrooms, int totalocc);
int main ()
{
//Declaration
int occ, empty, totalrooms, floors, totalfloors, hbfloor, totalocc;
double occrate;
totalrooms =
cout << "The hotel has a total of" << totalrooms << endl;
cout << occ << "are occupied." << endl;
cout << empty << "are empty." << endl;
cout << " The occupancy rate is " << occrate << endl;
cout << "The heart break floor is " << hbfloor << "with" << empty << "empty rooms.\n";
system ("pause");
return 0;
}
//
int getfloors()
{
int employees, floors;
cout << "How many floors does the hotel have? ";
cin >> floors;
while (floors < 1)
{
cout << "The number of floors must be greater than 1. Please re-enter: ";
cin >>floors;
}
return floor;
}
int getrooms(int occ)
{
int k, rooms, totalrooms;
for (k=1; k <= rooms; k++)
{ if ( k == 2 )
continue;
cout << "How many rooms are on floor" << k << "?";
cin >> rooms;
while (rooms < 9)
{
cout << "Rooms must exceed 9 rooms, please re-enter:" ;
cin >> rooms;
}
totalrooms += rooms;
}
return totalrooms;
}
int getocc(int rooms)
{
int k, occ, occrate;
for (k=1; k <= rooms; k++)
{
cout << "How many of those rooms are on occupied" << k << "?";
cin >> occ;
while (occ < rooms)
{
cout << "Occupancy cannot exceed the amount of rooms, please re-enter :" ;
cin >> occ;
}
totalocc += occ;
}
return totalocc;
}
double getoccrate(int totalrooms, int totalocc)
{
double occrate;
occrate = totalrooms / double (occ) * 100;
return occrate;
}
int getempty(int occ, int totalrooms)
{
int empty;
empty = totalrooms - occ;
return empty;
}
|
i realize that the code isn't complete, but that's the help i need. I need help finishing it and correcting the many errors i have.
Here are the instruction I am attempting to follow:
Write a complete C++ program to calculate the occupancy rate for the HeartBreak Hotel. The program should begin by asking for the number of floors. The program should then ask for the total number of rooms on each floor and how many of those are currently occupied. After all the floor information is entered, the program displays how many total rooms the hotel has, how many of them are occupied, how many are unoccupied and the percentage of rooms that are occupied. Also print which floor is the Heartbreak floor – that is, the floor with the most empty rooms.
Additional Requirements:
• You may use a for loops for your looping control structure.
• Your program should validate that the number of floors is at least 1. Use a while loop to validate the input and display an appropriate error message.
• Each floor must have at least 10 rooms. Use a while loop to validate the input and display an appropriate error message.
• The number of rooms occupied for each floor must not exceed the number of room on the floor and cannot be less than zero. Use a while loop to validate the input and display an appropriate error message.
• The HeartBreak Hotel is renovating the 2nd floor. The loop in this program should skip all processing of the 2nd floor.
• Display the percentage value in standard percent format with one decimal place.
program looks like this when ran
How many floors does the hotel have?
How many rooms are on floor 1
how many of those are occupied
how many rooms are on floor 3
how many are occupied
etc, etc then the final summing up of all the info
thanks again for everything