Question: My homework is write a prgram for hotel occupancy rate. I figured out everything expect occupacy rate of the floor. How to calculate occupancy rate

My homework is write a prgram for hotel occupancy rate. I figured out everything expect occupacy rate of the floor. How to calculate occupancy rate of each floor?

import java.util.Scanner;

public class Hwk6 {

public static void main(String[] args) {

int floors = 0;

int rooms = 0;

int roomsTotals = 0;

double roomsOccupied = 0;

double roomsOccupiedTotals = 0;

double occupancyRate = 0;

Scanner stdin = new Scanner(System.in);

System.out.println(" Hotel room occupacy rate calculator ");

System.out.print("Enter the number of floors: ");

floors = stdin.nextInt();

while(floors < 1) {

System.out.print("The number of floors must greater than 0. ");

floors = stdin.nextInt();

}

for(int i=0; i

System.out.print("Enter the number of rooms [Floor " + (int)(i + 1) + "]: ");

rooms = stdin.nextInt();

while(rooms < 8){

System.out.print("The minimum number of rooms are 8. [Floor " + (int)(i + 1) + "]: ");

rooms = stdin.nextInt();

}

System.out.print("Enter the number of rooms occupied [Floor " + (int)(i + 1) + "]: ");

roomsOccupied = stdin.nextInt();

roomsOccupiedTotals += roomsOccupied;

roomsTotals += rooms;

occupancyRate = (roomsOccupiedTotals/roomsTotals);

}

System.out.println("Total Rooms: " + roomsTotals);

System.out.println("Occupacy rate for entire hotel: " + occupancyRate);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!