Re: Project Nursing Home Due Tonight Help
What help do you need? Where are you stuck? Or are you just hoping for a group effort?
Re: Revised Project Nursing Home
Do the project in separate steps.
Display messages and get user responses
Compute values and display them.
Later when that works, work on using a loop for multiple sets of input.
What do you have coded now? Be sure to wrap posted code in code tags:
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: Revised Project Nursing Home
Please explain what you have finished and what are having problems with.
What is on the console when the program executes?
On Windows: To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Please edit your post and wrap your code with code tags:
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: Revised Project Nursing Home
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");
}
}
}
----jGRASP exec: java Project2Morris
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
----jGRASP: operation complete.
----jGRASP exec: java Project2Morris
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
----jGRASP: operation complete.
--- Update ---
using jgrasp
Re: Project Nursing Home Due Tonight Help
Please edit your post and wrap your code with code tags:
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
What are you having problems with?
Re: Project Nursing Home Due Tonight Help
not sure how to do that. Im a beginner
--- Update ---
using jgrasp
--- Update ---
my occupancy rate doesn't compute right also all my if else if statements aren't being executed to get my high, low or average occupancy rates. Next thing after that is how to get it to loop for my next building if I enter more than 1. Say I enter 4. Or 3 floors for my number of floors.
--- Update ---
Hope I'm breaking it down a little more. Im working at my job and shouldn't be on the computer getting homework done lol
Re: Project Nursing Home Due Tonight Help
Quote:
my occupancy rate doesn't compute right
what value is computed? what should the value be? Check your math to see how it should be computed. The rates would be from 0 to 100%
How do you compute percent?
To wrap the code in code tags:
put this in front of the code: [code]
and this after: [/code]
Re: Project Nursing Home Due Tonight Help
Code :
import java.text.DecimalFormat; //Needed to format occupancy rate as percentage
Code :
import java.util.Scanner; //Needed for the scanner class
Code :
// This program was created by Michael Morris
[/code][/code]
Code :
/** This program will determine the occupancy rate for multiple
nursing home
*/
Code :
public class Project2Morris
{[/code]
Code :
public static void main(String[] args)
{[/code]
Code :
int numBuildings; //Number of nursing homes
Code :
int numfloors; //Number of floors in the nursing home
Code :
int numRoomsFloor; //Number of rooms on the floor
Code :
int numOccupiedRooms; //Number of occupied rooms on the floor
Code :
int totalNumBuildings; //Accumulator for number of buildings
Code :
DecimalFormat formatter = new DecimalFormat("%#0")
;
Code :
Scanner keyboard = new Scanner (System.in);
Code :
System.out.print("Enter the number of nursing homes: ");
Code :
numBuildings = keyboard.nextInt();
Code :
System.out.println("Nursing Home:" +numBuildings);
Code :
totalNumBuildings = numBuildings;
{
Code :
System.out.println("Invalid entry: Number of buildings must be greater than 0.");
Code :
System.out.println("Reenter the number of buildings:");
numBuildings = keyboard.nextInt();[/code]
Code :
}
[code] System.out.print("How many floors are in the nursing home ?");
numfloors = keyboard.nextInt();[/code]
Code :
System.out.println("Invalid entry: Floors must be greater than 0.");
Code :
System.out.println("Reenter the number of floors in nursing home.");
numfloors = keyboard.nextInt();[/code]
Code :
System.out.print("How many rooms does floor have?");
numRoomsFloor = keyboard.nextInt();[/code]
Code :
System.out.println("Number of rooms:" +numRoomsFloor);
Code :
System.out.println("Invalid entry: Rooms cannot be less than 10.");
Code :
System.out.println("Reenter the number of Rooms.");
numRoomsFloor = keyboard.nextInt();[/code]
Code :
System.out.println("How many occupied rooms are on the floor?");
numOccupiedRooms = keyboard.nextInt();[/code]
Code :
while (numOccupiedRooms<=0)
[/code]
Code :
System.out.println("Invalid entry: Occupied rooms must be 0 or greater.");
[code] System.out.println("Reenter number of occupied rooms on the floor.");
numOccupiedRooms = keyboard.nextInt(); [/code]
[code]}
Code :
System.out.println("Occupied Rooms:" +numOccupiedRooms);
Code :
occupancyRate = numRoomsFloor / numOccupiedRooms;
Code :
vacantRooms = numRoomsFloor - numOccupiedRooms;
Code :
System.out.println("Vacant rooms:" +vacantRooms);
Code :
System.out.println("occupancy rate:" +occupancyRate);
[code] {
Code :
System.out.println("Occupancy Rate is High");
[code] }
Code :
else if (occupancyRate==50 && occupancyRate==74)
Code :
System.out.println("Occupancy Rate is Average");
Code :
}
[code] else if (occupancyRate>50)
[/code]
Code :
System.out.println("Occupancy Rate is Low");
______________________________
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 ---
Hope someone can help I have a deadline at 11 p.m
Re: Project Nursing Home Due Tonight Help
Did you look at what you posted? The tags go before and after the full contents of ALL the code, not around each statement.
You missed answering these questions:
what value is computed? what should the value be? Check your math to see how it should be computed. The rates would be from 0 to 100%
How do you compute percent?
Wrapped code would look like this:
Code :
// Define inner Scanner call for testing <<<<<<<<<<<<<<<<<<<<<<<<<
static class Scanner { // 4/29/13
static java.util.Scanner myScnr; // Save real scanner here
public Scanner(Object o) {
if (myScnr == null) { // Put responses here
myScnr = new java.util.Scanner("\nNo\n");
}
}
public Scanner(java.io.File f) throws java.io.FileNotFoundException {
if(!f.exists())
throw new java.io.FileNotFoundException(f.getName());
//?????
System.out.println(">>> No Scanner code for file: " + f);
}
public int nextInt() {
int val = myScnr.nextInt();
System.out.println("val="+val); // show response and give NL
return val;
}
public double nextDouble() {
double val = myScnr.nextDouble();
System.out.println("val="+val);
return val;
}
public String nextLine() {
String val = myScnr.nextLine();
System.out.println("val="+val);
return val;
}
public String next() {
String val = myScnr.next();
System.out.println("val="+val);
return val;
}
public void close() {}
} // end testing Scanner class <<<<<<<<<<<<<<<<<<<<<<
Re: Project Nursing Home Due Tonight Help
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();
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();
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");
}
}
}
ÏÏÏÏ
ÏÏ«Ï ----jGRASP exec: java Project2Morris
ÏϧÏ
¼¼§Ï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
ÏϧÏ
ÏÏ©Ï ----jGRASP: operation complete.
ÏÏÏÏ
ÏÏ«Ï ----jGRASP exec: java Project2Morris
ÏϧÏ
¼¼§Ï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
ÏϧÏ
ÏÏ©Ï ----jGRASP: operation complete.
ÏÏÏÏ
ÏÏ«Ï ----jGRASP exec: java Project2Morris
ÏϧÏ
¼¼§ÏEnter the number of nursing homes: 2
¼¼§ÏHow many floors are in the nursing home ?1
¼¼§ÏHow many rooms does floor have?20
ÏϧÏHow many occupied rooms are on the floor?
¼¼§Ï15
ÏϧÏOccupied Rooms:15
ÏϧÏVacant rooms:5
ÏϧÏoccupancy rate:1.0
ÏϧÏ
ÏÏ©Ï ----jGRASP: operation complete.
¼¼ÏÏ
occupancyRate = numRoomsFloor / numOccupiedRooms; //This is my occupancyRate formula
Re: Project Nursing Home Due Tonight Help
Quote:
occupancyRate = numRoomsFloor / numOccupiedRooms; //This is my occupancyRate formula
So if there are 100 rooms and 1 is occupied then the rate is 100/1 = 100 or 10000%
That doesn't see right.
I'd think the rate would be 1% (1/100 * 100)
Re: Project Nursing Home Due Tonight Help
Quote:
Originally Posted by
Norm
So if there are 100 rooms and 1 is occupied then the rate is 100/1 = 100 or 10000%
That doesn't see right.
I'd think the rate would be 1% (1/100 * 100)
Im Plugging In 20 for numRooms Divided By 15 numroomsoccupied And Getting 1.0 futhermore None Of My If Else Staements Are being Executed. Getting Very frustrated Havent Failed An Assignment Yet.
Re: Project Nursing Home Due Tonight Help
Do some research on how to compute percent.
If there are 20 rooms and 15 are occupied, what percent of the rooms are occupied?
Quote:
None Of My If Else Staements Are being Executed.
The posted code does not show the end of the if/else if statement so I can't help you without seeing all of the statements.
Re: Project Nursing Home Due Tonight Help
Quote:
Originally Posted by
Norm
Do some research on how to compute percent.
If there are 20 rooms and 15 are occupied, what percent of the rooms are occupied?
The posted code does not show the end of the if/else if statement so I can't help you without seeing all of the statements.
It Should Be 75 or .75 as A Decimal. This Shouldnt Be Complicated. I Can Use Decimalformat To have It Show As A Percent If It At Least Computed As The Correct Decimal.
--- Update ---
My if else statements are in ealier threads at the top and middle towards the end of my program. Thank you for your time,
Re: Project Nursing Home Due Tonight Help
Do you have the formula for computing percent now? How did you get 75% for those numbers? What is the formula?
Code :
if (occupancyRate==50 && occupancyRate==74)
When would this statement be true? For what values?
You need to look at your code and see if it does what you intend.
Re: Project Nursing Home Due Tonight Help
So your saying number of occupied rooms / number rooms shoupdnt give you .75.
20/15 is .75 im Not Concerned With Having It Print As A Percentage.
My Instructions Were To Print Average Occupancy Rate If Between 50 and 74 thats Were Im Getting The If Statement From.
Re: Project Nursing Home Due Tonight Help
Quote:
Instructions Were To Print Average Occupancy Rate If Between 50 and 74
Look at that statement again. What is it testing?
Use English to describe how to test if a number is between 50 and 74. What two comparisons would need to be made.
Do you have a calculator? What is 20 divided by 15? It is NOT .75