Having major problems getting this program due tonight. Never had a problem with the basic programs as a beginner but this is too much. It's due tonight and no I didn't procrastinate I'm just not good at programming yet.
I have the code displayed here and well as my assignment (ie input and output expected). Please help me, I understand the concepts but putting it into a real complete program is killing me. Love to code but getting overwhelmed.
__________________________________________________ ___________________________________________
import java.text.DecimalFormat; //Needed to format occupancy rate as percentage
import java.util.Scanner; //Needed for the scanner class
// This program was created by Michael Morris
/** This program will determine the occupancy rate for multiple
nursing home
*/
public class Project2Morris
{
public static void main(String[] args)
{
int numBuildings; //Number of nursing homes
int numfloors; //Number of floors in the nursing home
int numRoomsFloor; //Number of rooms on the floor
int numOccupiedRooms; //Number of occupied rooms on the floor
int vacantRooms;
double occupancyRate;
int totalNumBuildings; //Accumulator for number of buildings
DecimalFormat formatter = new DecimalFormat("%#0");
Scanner keyboard = new Scanner (System.in);
totalNumBuildings = 0;
System.out.print("Enter the number of nursing homes: ");
numBuildings = keyboard.nextInt();
System.out.println("Nursing Home:" +numBuildings);
totalNumBuildings = numBuildings;
while (numBuildings<=0)
{
System.out.println("Invalid entry: Number of buildings must be greater than 0.");
System.out.println("Reenter the number of buildings:");
numBuildings = keyboard.nextInt();
}
System.out.print("How many floors are in the nursing home ?");
numfloors = keyboard.nextInt();
while (numfloors<=0)
{
System.out.println("Invalid entry: Floors must be greater than 0.");
System.out.println("Reenter the number of floors in nursing home.");
numfloors = keyboard.nextInt();
}
System.out.print("How many rooms does floor have?");
numRoomsFloor = keyboard.nextInt();
System.out.println("Number of rooms:" +numRoomsFloor);
while (numRoomsFloor<10)
{
System.out.println("Invalid entry: Rooms cannot be less than 10.");
System.out.println("Reenter the number of Rooms.");
numRoomsFloor = keyboard.nextInt();
}
System.out.println("How many occupied rooms are on the floor?");
numOccupiedRooms = keyboard.nextInt();
while (numOccupiedRooms<=0)
{
System.out.println("Invalid entry: Occupied rooms must be 0 or greater.");
System.out.println("Reenter number of occupied rooms on the floor.");
numOccupiedRooms = keyboard.nextInt();
}
System.out.println("Occupied Rooms:" +numOccupiedRooms);
occupancyRate = numRoomsFloor / numOccupiedRooms;
vacantRooms = numRoomsFloor - numOccupiedRooms;
System.out.println("Vacant rooms:" +vacantRooms);
System.out.println("occupancy rate:" +occupancyRate);
if (occupancyRate>75)
{
System.out.println("Occupancy Rate is High");
}
else if (occupancyRate==50 && occupancyRate==74)
{
System.out.println("Occupancy Rate is Average");
}
else if (occupancyRate>50)
{
System.out.println("Occupancy Rate is Low");
}
}
}
__________________________________________________ ____________________________________________
Project Description
The owner of the Sunshine Nursing Home would like you to modify your program so the program can be used to determine the occupancy rate for multiple nursing homes.
Modify Project 1 as follows:
Input validation:
• Do not accept a value less than 1 for the number of nursing homes.
• Do not accept a value less than 1 for the number of floors in a nursing home.
• Do not accept a number less than 10 for the number of rooms on a floor.
• Do not accept a number less than 0 for the number of occupied rooms.
• Do not accept a number for occupied rooms that is higher than the actual number of rooms for the related floor
The program should display:
• The nursing home number.
• The total number of rooms in each nursing home.
• The total number of occupied rooms in each nursing home.
• The total number of vacancies in each nursing home.
• The occupancy rate for each nursing home (the occupancy rate should be displayed as a percentage).
• The program should display "Occupancy Rate is High" if the occupancy rate is above 75%; “Occupancy Rate is Average” if the occupancy rate is 50 – 74% and “Occupancy Rate is Low” if the occupancy rate is below 50%.
Sample Input and Output for Two Nursing Homes
Sample Input Number of buildings: 0
Invalid entry: Number of buildings must be greater than 0.
Reenter the number of buildings: 2
How many floors are in Nursing Home 1? 0
Invalid entry: Floor(s) must be greater than 0.
Reenter the number of floors: 1
How many rooms does floor 1 have? 9
Invalid entry: Rooms cannot be less than 10.
Reenter the number of rooms: 20
How many occupied rooms are on floor 1? -1
Invalid entry: Occupied rooms must be 0 or greater. Reenter: 15
Nursing Home 1
Number of rooms: 20
Occupied rooms: 15
Vacant rooms: 5
Occupancy rate: 75%
Occupancy Rate is High
How many floors are in Nursing Home 2? 3
How many rooms does floor 1 have? 20
How many occupied rooms are on floor 1: 5
How many rooms does floor 2 have? 20
How many occupied rooms are on floor 2? 8
How many rooms does floor 3 have? 20
How many occupied rooms are on floor 3? 11
Nursing Home 2
Number of rooms: 60
Occupied rooms: 24
Vacant rooms: 36
Occupancy rate: 40%
Occupancy Rate is Low
Compiled and ran the code but this is not what my professor is looking for. Not sure were to start.
Enter the number of nursing homes: 2
Nursing Home:2
How many floors are in the nursing home ?1
How many rooms does floor have?20
Number of rooms:20
How many occupied rooms are on the floor?
15
Occupied Rooms:15
Vacant rooms:5
occupancy rate:1.0
--- Update ---
mY occucpancy caculations aren't correct and my if else if statements to display whether the occupancy rate is high, average, or low
doesn't work. Not sure if I'm doing the number of buildings right should this be looping.
Need help badly
I have while loops to make sure I have the proper input. Other than that pretty lost. Help get me started
Not looking for you to code it. Just an overall structure of whtat to go on.
Sample Input
Number of buildings: 0
Invalid entry: Number of buildings must be greater than 0.
Reenter the number of buildings: 2
How many floors are in Nursing Home 1? 0
Invalid entry: Floor(s) must be greater than 0.
Reenter the number of floors: 1
How many rooms does floor 1 have? 9
Invalid entry: Rooms cannot be less than 10.
Reenter the number of rooms: 20
How many occupied rooms are on floor 1? -1
Invalid entry: Occupied rooms must be 0 or greater. Reenter: 15
Nursing Home 1
Number of rooms: 20
Occupied rooms: 15
Vacant rooms: 5
Occupancy rate: 75%
Occupancy Rate is High
How many floors are in Nursing Home 2? 3
How many rooms does floor 1 have? 20
How many occupied rooms are on floor 1: 5
How many rooms does floor 2 have? 20
How many occupied rooms are on floor 2? 8
How many rooms does floor 3 have? 20
How many occupied rooms are on floor 3? 11
Nursing Home 2
Number of rooms: 60
Occupied rooms: 24
Vacant rooms: 36
Occupancy rate: 40%
Occupancy Rate is Low
--- Update ---
Can i please get a flowchart or at least a partiap one. Only been coding 8 wks and Have an Assignment Due That Pve Worked On For 2 days. Please Help Dont Want To Fail This Projrct. Ill Write My Own Code. But It Seems Theres Some Kind Of Loop When I Pick Numbr Of Buipdings That Will Allow to Keep Inputing Ingormation For As many Buildings As I Specify. Look at Sample Input 1 And 2 Finding The Input and Output For 1 is Simple But For Many Not Sure.
This is to compute the occupancy rate for multiple nursing homes very confused need help
_Sample Input_________________________
Number of buildings: 0
Invalid entry: Number of buildings must be greater than 0.
Reenter the number of buildings: 2
How many floors are in Nursing Home 1? 0
Invalid entry: Floor(s) must be greater than 0.
Reenter the number of floors: 1
How many rooms does floor 1 have? 9
Invalid entry: Rooms cannot be less than 10.
Reenter the number of rooms: 20
How many occupied rooms are on floor 1? -1
Invalid entry: Occupied rooms must be 0 or greater. Reenter: 15
Nursing Home 1
Number of rooms: 20
Occupied rooms: 15
Vacant rooms: 5
Occupancy rate: 75%
Occupancy Rate is High
How many floors are in Nursing Home 2? 3
How many rooms does floor 1 have? 20
How many occupied rooms are on floor 1: 5
How many rooms does floor 2 have? 20
How many occupied rooms are on floor 2? 8
How many rooms does floor 3 have? 20
How many occupied rooms are on floor 3? 11
Nursing Home 2
Number of rooms: 60
Occupied rooms: 24
Vacant rooms: 36
Occupancy rate: 40%
Occupancy Rate is Low
Can i please get a flowchart or at least a partiap one. Only been coding 8 wks and Have an Assignment Due That Pve Worked On For 2 days. Please Help Dont Want To Fail This Projrct. Ill Write My Own Code. But It Seems Theres Some Kind Of Loop When I Pick Numbr Of Buipdings That Will Allow to Keep Inputing Ingormation For As many Buildings As I Specify. Look at Sample Input 1 And 2 Finding The Input and Output For 1 is Simple But For Many Not Sure.
Here is my code:
import java.text.DecimalFormat; //Needed to format occupancy rate as percentage
import java.util.Scanner; //Needed for the scanner class
// This program was created by Michael Morris
/** This program will determine the occupancy rate for multiple
nursing home
*/
public class Project2Morris
{
public static void main(String[] args)
{
int numBuildings; //Number of nursing homes
int numfloors; //Number of floors in the nursing home
int numRoomsFloor; //Number of rooms on the floor
int numOccupiedRooms; //Number of occupied rooms on the floor
int vacantRooms;
double occupancyRate;
int totalNumBuildings; //Accumulator for number of buildings
DecimalFormat formatter = new DecimalFormat("%#0");
Scanner keyboard = new Scanner (System.in);
totalNumBuildings = 0;
System.out.print("Enter the number of nursing homes: ");
numBuildings = keyboard.nextInt();
System.out.println("Nursing Home:" +numBuildings);
totalNumBuildings = numBuildings;
while (numBuildings<=0)
{
System.out.println("Invalid entry: Number of buildings must be greater than 0.");
System.out.println("Reenter the number of buildings:");
numBuildings = keyboard.nextInt();
}
System.out.print("How many floors are in the nursing home ?");
numfloors = keyboard.nextInt();
while (numfloors<=0)
{
System.out.println("Invalid entry: Floors must be greater than 0.");
System.out.println("Reenter the number of floors in nursing home.");
numfloors = keyboard.nextInt();
}
System.out.print("How many rooms does floor have?");
numRoomsFloor = keyboard.nextInt();
System.out.println("Number of rooms:" +numRoomsFloor);
while (numRoomsFloor<10)
{
System.out.println("Invalid entry: Rooms cannot be less than 10.");
System.out.println("Reenter the number of Rooms.");
numRoomsFloor = keyboard.nextInt();
}
System.out.println("How many occupied rooms are on the floor?");
numOccupiedRooms = keyboard.nextInt();
while (numOccupiedRooms<=0)
{
System.out.println("Invalid entry: Occupied rooms must be 0 or greater.");
System.out.println("Reenter number of occupied rooms on the floor.");
numOccupiedRooms = keyboard.nextInt();
}
System.out.println("Occupied Rooms:" +numOccupiedRooms);
occupancyRate = numRoomsFloor / numOccupiedRooms;
vacantRooms = numRoomsFloor - numOccupiedRooms;
System.out.println("Vacant rooms:" +vacantRooms);
System.out.println("occupancy rate:" +occupancyRate);
if (occupancyRate>75)
{
System.out.println("Occupancy Rate is High");
}
else if (occupancyRate==50 && occupancyRate==74)
{
System.out.println("Occupancy Rate is Average");
}
else if (occupancyRate>50)
{
System.out.println("Occupancy Rate is Low");
}
}
}