Writ a program using java. Depending on the size of the room and the amount of shade that the room has, different sizes of air conditioning units must be used in order to be able to properly cool the room. The unit of measure for the amount of cooling that an air conditioner unit can provide is the BTU (British Thermal Unit) per hour. Code a program that will calculate the correct size of air conditioner for a specific room size using the instructions below. Step 1: Ask the user to enter the length of their room (in feet). Step 2: Ask the user to enter the width of their room (in feet). Step 3: Calculate the area (in square feet) of the room by multiplying the length and the width of the room. For example, if a room is 20 feet wide by 24 feet long, then its area is 20 * 24 = 480 square feet Step 4: Display a menu that asks the user how much shade the room gets. The menu should have the following options: Little Shade Moderate Shade Abundant Shade Step 5
Determine the capacity of the air conditioning unit that is needed for a moderately shaded room by using the information in the table below.
Room Size (Square Feet) |
Air Conditioner Capacity (in BTUs per Hour) |
Under 250 |
5,500 |
From 250 to 500 |
10,000 |
Over 500 to Under 1000 |
17,500 |
1000 or Greater |
24,000 |
If the room has little shade, then the BTU capacity should be increased by 15% since the air conditioning unit must be able to produce extra cooling.
If the room has abundant shade, then the BTU capacity should be decreased by 10% since the air conditioning unit does not need to work as hard to cool a shaded room.
Step 6:
Create a String object in memory to hold the text “Air Conditioning Window Unit Cooling Capacity”. Display that text at the top of the output.
Step 7:
Display the following output:
computer science
:
Code:
import java.util.Scanner;
class CalculateBHU
{
public static void main(String args[])
{
// Scanner object is used
to read input from the user
Scanner input = new
Scanner(System.in);
// Prompting the user to
enter length
System.out.print("Enter the room
length in feet:");
// Reading the
length
int roomLength =
input.nextInt();
// Prompting the user to
enter width
System.out.print("Enter the room
width in feet:");
// Reading the
width
int roomWidth =
input.nextInt();
// Calculating the area of
the room
int roomArea = roomLength *
roomWidth;
// This variable is used to
store the capacity of the air conditioner needed for the
room
double airConditionerCapacity =
0;
// If the area is less than
250
if(roomArea < 250)
{
airConditionerCapacity = 5500;
}
// If the area is greater
than or equal to 250 and less than 500
else if(roomArea>=250 &&
roomArea<500)
{
airConditionerCapacity = 10000;
}
// If the area is greater
than or equal to 500 and less than 1000
else if(roomArea>=500 &&
roomArea < 1000)
{
airConditionerCapacity = 17500;
}
// If the area is greater
than or equal to 1000
else if(roomArea >=1000)
{
airConditionerCapacity = 24000;
}
// Prompting the user to
enter the amount of shade the room gets
System.out.println("Select the
amount of shade the room gets");
System.out.println("1.Little
Shade");
System.out.println("2.Moderate
Shade");
System.out.println("3.Abundant
Shade");
System.out.print("Enter your
choice:");
// Reading the shade choice
from the user
int roomShadeChoice =
input.nextInt();
// If the shade the room
gets is little
if(roomShadeChoice == 1)
{
//
Increase the airConditionerCapacity by 15 percent
airConditionerCapacity += (airConditionerCapacity * 0.15);
}
// If the shade the room
gets is abundant
else if(roomShadeChoice == 3)
{
//
Decrease the airConditionerCapacity by 10 percent
airConditionerCapacity -= (airConditionerCapacity *
0.10);
}
// This contains the text
which is printed first on the output
String outputStart = "Air
conditioning Window Unit Cooling Capacity";
// Printing the starting
text and area of the room
System.out.println(outputStart);
System.out.println("The area of the
room is " + roomArea + " sqft");
// Printing the shade of
the room
System.out.print("The amount of
shade that room gets is ");
if(roomShadeChoice == 1)
{
System.out.println("little");
}
else if(roomShadeChoice == 3)
{
System.out.println("abundant");
}
else
{
System.out.println("moderate");
}
// Printing the BTU's per
hour needed for room to cool down
System.out.printf("The number of
BTU's per hour that are needed to cool the room :
%d\n",(int)Math.ceil(airConditionerCapacity));
}
}
Sample Output:
Get Answers For Free
Most questions answered within 1 hours.