Input Validation: Do not accept a number less than 1 for the number of floors. Do not accept a number less than
10 for the number of rooms on a floor.
Occupancy rate = number of rooms occupied ÷ total number of rooms
As far as I can see from this program, I believe I need to use a for loop. The problem is that I really don't know how to do it or in other words what exactly to put in the for loop. Here is what I have so far:
import java.util.Scanner;
public class HotelOccupancy
{
public static void main(String[ ] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("How many floors does the hotel has? ");
double floors;
input = keyboard.nextDouble();
System.out.print("How many rooms are on each floor? ");
double rooms;
input = keyboard.nextDouble();
System.out.print("How many rooms are occupied? ");
double occupied;
input = keyboard.nextDouble();
}
}
Thank you for your help!

New Topic/Question
Reply




MultiQuote



|