0% found this document useful (0 votes)
33 views

Answer Scheme Lab Assessment

The C++ code prompts the user to input the number of floors in a hotel and the number of rooms on each floor. It then prompts for the number of occupied rooms on each floor. It calculates and outputs the total number of rooms, occupied rooms, unoccupied rooms, and percentage of occupied rooms. The sample output will vary depending on the user input.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Answer Scheme Lab Assessment

The C++ code prompts the user to input the number of floors in a hotel and the number of rooms on each floor. It then prompts for the number of occupied rooms on each floor. It calculates and outputs the total number of rooms, occupied rooms, unoccupied rooms, and percentage of occupied rooms. The sample output will vary depending on the user input.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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

You might also like