what is wrong with it I have no idea and by staring at the program I am not getting any lcuk
pls help
thanks
Program by: Hope
FileName: Hope_10
Program Description: Hotel Occupancy
Problem Statement: Write a program that calculates the occupancy rate for each floor of a hotel.
The program should start by asking for the number of floors that the hotel has.
A loop should then iterate once for each floor. During each iteration, the loop
should ask the user for the number of rooms on the floor and the number of them
that are occupied. After all the iterations, the program should display the number
of rooms the hotel has, the number of them that are occupied, the number that are
vacant, and the occupancy rate for the hotel. Program should not accept a number
less than one for the number of floors, and a number less than 10 for the number
of rooms on a floor
import java.util.Scanner;
public class Hope_10
{
public static void main (String[ ] args)
{
//Scanner Object
Scanner keyboard = new Scanner(System.in);
//Declaring variables
int Floors=0;
int Rooms;
int Occupied;
double Occupancy_Rate=0;
int Count;
int Total_Rooms=0;
int Total_Occupied=0;
int Rooms_Vacant=0;
System.out.println("How many floors are in the hotel? ");
Floors = keyboard.nextInt();
System.out.println();//Blank space
//Validate the Input for floors
while (Floors<1)
{
System.out.println("Number of floor must be greater than zero!");
System.out.println();//Blank Space
System.out.println("How many floors are in the hotel? ");
Floors = keyboard.nextInt();
System.out.println();//Blank Space
}
for (Count=1;Count<Floors+1;Count++)
{
System.out.println("How many rooms are there on floor "+Count+"? ");
Rooms = keyboard.nextInt();
System.out.println();//Blank Space
//Validate input of rooms - 10 or more
while (Rooms<10)
{
System.out.println("Number of rooms must be greater than ten!");
System.out.println();//Blank Space
System.out.println("How many rooms are on floor "+Count+"? ");
Rooms = keyboard.nextInt();
}
System.out.println();//Blank Space
System.out.print("How many rooms on floor "+Count+" are occupied? ");
Occupied=keyboard.nextInt();
Total_Rooms+=Rooms;
Total_Occupied+=Occupied;
}
//All floors counted
//Calculation for the occupancy rate
Occupancy_Rate = (Total_Occupied / Total_Rooms)*100;
//Calculation for vacant
Rooms_Vacant = Total_Rooms-Total_Occupied;
System.out.println();//Blank Space
System.out.println("There are "+ Total_Rooms+" rooms, "+Total_Occupied+" of them are occupied");
System.out.println("There are "+Rooms_Vacant+ " vacant, and occupancy rate is "+Occupancy_Rate+ "%.");
}
}
~edit: code tags PB
This post has been edited by jayman9: 04 November 2007 - 10:02 PM

New Topic/Question
Reply




MultiQuote






|