Answer Scheme Lab Assessment
LAB 5: QUESTION 3
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
int numfloor=0, numroom=0, numroomOcc=0;
double totnumroom=0, totroomOcc=0, totroomVacant=0;
double precentroomOcc = 0.0;
cout << "Number of hotel floors : ";
cin >> numfloor;
cout << endl;
for (int i=0; i<numfloor; i++)
{
cout << "Number of rooms for Floor-" << i+1 << " : ";
cin >> numroom;
cout << "Number of occupies rooms : " << i+1 << " : ";
cin >> numroomOcc;
totnumroom = totnumroom + numroom;
totroomOcc = totroomOcc + numroomOcc;
totroomVacant = totroomVacant + (numroom - numroomOcc);
cout << endl;
}
precentroomOcc = (totroomOcc / totnumroom) * 100;
cout << "Total of rooms : " << totnumroom << endl;
cout << "Total of occupied rooms : " << totroomOcc << endl;
cout << "Total of unoccupied rooms : " << totroomVacant << endl;
cout << "Percentage of occupied rooms : " << precentroomOcc << setprecision(2) << "%" << endl
<< endl;
}
SAMPLE OUTPUT
Notes:
The answer may varies, depends on the students’ logic.
The concepts used are counted.
BITG1233 | Sem 1 2016/2017
1