Computer Science, asked by vandana2kota, 3 days ago

Sample input 1 > Sample output 1 4 2 NO 1 6 39 YES 1 2 1 3 34 1 4 @ 1 4 10​

Attachments:

Answers

Answered by mundelmukund1986
0

Answer:

#include <iostream>

using namespace std;

int main(){

int number_of_floors, number_of_rooms_in_floor, occupied_rooms_in_floor;

int total_occupied_rooms = 0, total_unonccupied_rooms = 0, total_number_of_rooms = 0;

do{

cout<<"Input the number of floors in hotel: ";

cin>>number_of_floors;

}while(number_of_floors < 1);

for(int i = 0; i < number_of_floors; i++){

do{

cout<<"Input the number of rooms in floor "<<i + 1<<endl;

cin>>number_of_rooms_in_floor;

}while(number_of_rooms_in_floor < 10);

total_number_of_rooms += number_of_rooms_in_floor;

do{

cout<<"Input the number of occupied rooms in floor "<<i + 1<<endl;

cin>>occupied_rooms_in_floor;

}while(occupied_rooms_in_floor < 0);

total_occupied_rooms += occupied_rooms_in_floor;

total_unonccupied_rooms += number_of_rooms_in_floor - occupied_rooms_in_floor;

}

float occupancy_rate = (float) total_occupied_rooms / total_number_of_rooms * 100;

cout<<"Total Number of rooms: "<<total_number_of_rooms<<endl;

cout<<"Total occupied rooms: "<<total_occupied_rooms<<endl;

cout<<"Total unoccupied rooms: "<<total_unonccupied_rooms<<endl;

cout<<"Occupancy rate: "<<occupancy_rate<<"%"<<endl;

return 0;

}

Similar questions