Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

Students also viewed these Databases questions