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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started