import java.util.Scanner;
public class lab3
{
public static void main(String[]args)
{
int floor;
int rooms;
int occupied;
int totalRooms;
int totalOccupied;
int totalVacant;
double occupancyRate;
Scanner keyboard=new Scanner(System.in);
System.out.println("Please enter the number of floors in the hotel: ");
floor=keyboard.nextInt();
while(floor<1)
{
System.out.println("The number of floors cannot less than 1, please re-enter: ");
floor=keyboard.nextInt();
}
totalRooms=0;
totalOccupied=0;
for(int i=1;i<=floor;i++)
{
System.out.println("Please enter the number of rooms in floor "+i+": ");
rooms=keyboard.nextInt();
while(rooms<10)
{
System.out.println("Number of rooms cannot less than 10, please re-enter: ");
rooms=keyboard.nextInt();
}
totalRooms+=rooms;
System.out.println("Please enter the number of occupied rooms: ");
occupied=keyboard.nextInt();
totalOccupied+=occupied;
keyboard.nextLine();
}
System.out.println("The total number of rooms in the hotel is "+totalRooms);
System.out.println("The total rooms occupied in the hotel is "+totalOccupied);
totalVacant=totalRooms-totalOccupied;
System.out.println("The total vacant rooms in the hotel is: "+totalVacant);
occupancyRate=totalOccupied / totalRooms;
System.out.println("The occupancy rate for the hotel is "+occupancyRate);
}
}
why the oocupancy rate is always zero after i compile?