Question

In: Computer Science

In some older homes that do not have a central heating and air conditioning system, smaller...

In some older homes that do not have a central heating and air conditioning system, smaller air conditioning units made to fit inside of a window and cool a single room are used as an alternative way to cool the home.

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 in Java 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). Should not be less than 5

Step 2:

Ask the user to enter the width of their room (in feet). Should not be less than 5

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:

  1. Little Shade
  2. Moderate Shade
  3. 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.

First, move any named constants from inside of your main method to above the main method and make them static by adding the “static” keyword in front of them. For example, “static final double TAX_RATE = .075;”. By doing this, all of the static methods you will create below will have access to your named constants so that you do not need to declare them locally in each method.

In addition to the main method, your code must include the following static methods:

Method 1 - displayTitle

A void method that displays the title

Method 2 – calculateArea

A method that accepts the length and width of a room as arguments, and calculates and returns the area of the room

Method 3 – translateShadeChoiceToString

A method that accepts an integer value (1, 2, or 3) that denotes the amount of shade. The method should return the appropriate String representation of the shade. For example, if the method is passed an integer value of 1, it should return a String with a value of “Little”.

Method 4 - calculateBTUsPerHour

A method that accepts the area of a room and the amount of shade a room gets and returns the BTUs per Hour that are needed to adequately cool that room.

Method 5 - displayRoomInformation

A void method that prints out the information for a single room. The output should look exactly the same as the output for Project 2. The method should accept only the arguments necessary to print out the information.

At the end of the output, in the main method, the program should display the number of rooms that have been entered.

Sample Input and Output (user input is in bold) - The output of your program should match the formatting and spacing exactly as shown

Please enter the name of the room: Guest Bedroom
Please enter the length of the room (in feet): 15.5
Please enter the width of the room (in feet): 10
What is the amount of shade that this room receives?

  1. Little Shade
  2. Moderate Shade
  3. Abundant Shade

Please select from the options above: 3

Air Conditioning Window Unit Cooling Capacity
Room Name: Guest Bedroom
Room Area (in square feet): 155.0

Solutions

Expert Solution

=======================

JAVA PROGRAM

=======================

////////////////AirConditioningCapacity.JAVA/////////////////////////

import java.util.Scanner;

/**
* Class: AirConditioningCapacity
* File: AirConditioningCapacity.java
* Purpose: To calculate ac unit capacity based on user input
*/
public class AirConditioningCapacity {
   //constants for different ac capacity based on room areas
   private static final double CAPACITY_FOR_ROOM_UNDER_250 = 5500;
   private static final double CAPACITY_FOR_ROOM_250_TO_500 = 10000;
   private static final double CAPACITY_FOR_ROOM_OVER_500_UNDER_1000 = 17500;
   private static final double CAPACITY_FOR_ROOM_1000_OR_GREATER = 24000;
  
   //constants defined for increase or decrease in capacity based on room shade
   private static final double CAPACITY_INCREASE_FOR_LITTLE_SHADE = 0.15; //15%
   private static final double CAPACITY_DECREASE_FOR_ABUNDANT_SHADE = 0.10; //10%
  
   //all room shades are defined in array
   private static final String[] roomShades = {"Little Shade","Moderate Shade","Abundant Shade"};
  
   //main method starts
   public static void main(String[] args){
       //scanner instance created
       Scanner sc = new Scanner(System.in);
      
       int roomCounter = 0; //this will keep track of number of rooms
      
       //continue to take rooms as long as user wants
       do{
           roomCounter++; //keep track of number of rooms entered
          
           System.out.println("Please enter the name of the room: ");
           String roomName = sc.nextLine(); //read name of room
          
           System.out.println("Please enter the length of the room (in feet): ");
           double length = Double.parseDouble(sc.nextLine());//read length
          
           System.out.println("Please enter the width of the room (in feet): ");
           double width = Double.parseDouble(sc.nextLine());//read width
          
           System.out.println("What is the amount of shade that this room receives?");
           for(String shade: roomShades){//print different room shades
               System.out.println(shade);
           }
          
           System.out.println("Please select from the options above: ");
           int amountOfShade = Integer.parseInt(sc.nextLine());//take data for amount of shade
           //translate room shade into String info
           String roomShade = translateShadeChoiceToString(amountOfShade);
           double area = calculateArea(length, width);   //calculate area of the room  
           double acCapacity = calculateBTUsPerHour(area, amountOfShade);//calculate capacity
           displayTitle();//print title
           displayRoomInformation(roomName, area);//display room info
           //additionally prints room shade
           System.out.println("Room Shade: "+roomShade);
           //finally prints capacity of the ac unit
           System.out.println("Capacity of the air conditioning unit "
                   + "(in BTU Per Hour): "+acCapacity);
          
           //checks if user wants to enter another room
           System.out.println("\nPress Y to enter another room or any other key to exit: ");
           String userChoice = sc.nextLine(); //read user's choice
           if(!userChoice.equalsIgnoreCase("Y")){ //if anything other than Y or y is entered
               break;//break out of the loop
           }
       }while(true);
      
       //print room counter
       System.out.println("Total number of rooms entered: "+ roomCounter);
   }
  
   /**
   * display title
   */
   public static void displayTitle(){
       System.out.println("Air Conditioning Window Unit Cooling Capacity");
   }
  
   /**
   * calculate area of the room
   * @param length
   * @param width
   * @return
   */
   public static double calculateArea(double length,double width){
       double area = 0;
       if(length > 0 && width > 0){
           area = length * width;
       }
       return area;
   }
  
   /**
   * convert amountOfShade to Stringequivlent
   * using roomShades array
   * @param amountOfShade
   * @return
   */
   public static String translateShadeChoiceToString(int amountOfShade){
       String shadeChoice = "Invalid Shade Choice";
       //if amount of shade is in range of number of shades
       if(amountOfShade >= 0 && amountOfShade <=roomShades.length){
           shadeChoice = roomShades[amountOfShade -1]; //take value from array
       }
      
       return shadeChoice;
   }
  
   /**
   * calculate capacity based on room area and amountOfShade
   * @param area
   * @param amountOfShade
   * @return
   */
   public static double calculateBTUsPerHour(double area,int amountOfShade){
       double capacityInBTUPerHour = 0;
      
       //check for different room sizes
       if(area < 250){
           capacityInBTUPerHour = CAPACITY_FOR_ROOM_UNDER_250;
       }else if(area >=250 && area <= 500){
           capacityInBTUPerHour = CAPACITY_FOR_ROOM_250_TO_500;
       }else if(area > 500 && area < 1000){
           capacityInBTUPerHour = CAPACITY_FOR_ROOM_OVER_500_UNDER_1000;
       }else if(area >= 1000){
           capacityInBTUPerHour = CAPACITY_FOR_ROOM_1000_OR_GREATER;
       }
      
       //check for different room shades
       if(amountOfShade ==1){ //for little shade increase by 15%
           capacityInBTUPerHour += capacityInBTUPerHour*CAPACITY_INCREASE_FOR_LITTLE_SHADE;
       }else if(amountOfShade ==2){ //for moderate shade no change
           //no change, keep it as it is
       }else if(amountOfShade == 3){//for abundant shade decrease by 10%
           capacityInBTUPerHour -= capacityInBTUPerHour*CAPACITY_DECREASE_FOR_ABUNDANT_SHADE;
       }
      
       return capacityInBTUPerHour;
   }
  
   /**
   * display room name and area
   * @param roomName
   * @param roomArea
   */
   public static void displayRoomInformation(String roomName,double roomArea){
       System.out.println("Room Name: "+roomName);
       System.out.println("Room Area (in square feet): "+roomArea);  
   }

}

==============================

OUTPUT

==============================

Please enter the name of the room:
Guest Bedroom
Please enter the length of the room (in feet):
15.5
Please enter the width of the room (in feet):
10
What is the amount of shade that this room receives?
Little Shade
Moderate Shade
Abundant Shade
Please select from the options above:
1
Air Conditioning Window Unit Cooling Capacity
Room Name: Guest Bedroom
Room Area (in square feet): 155.0
Room Shade: Little Shade
Capacity of the air conditioning unit (in BTU Per Hour): 6325.0

Press Y to enter another room or any other key to exit:
Y
Please enter the name of the room:
Dining Room
Please enter the length of the room (in feet):
25
Please enter the width of the room (in feet):
18.5
What is the amount of shade that this room receives?
Little Shade
Moderate Shade
Abundant Shade
Please select from the options above:
3
Air Conditioning Window Unit Cooling Capacity
Room Name: Dining Room
Room Area (in square feet): 462.5
Room Shade: Abundant Shade
Capacity of the air conditioning unit (in BTU Per Hour): 9000.0

Press Y to enter another room or any other key to exit:
Y
Please enter the name of the room:
Kitchen
Please enter the length of the room (in feet):
30
Please enter the width of the room (in feet):
12
What is the amount of shade that this room receives?
Little Shade
Moderate Shade
Abundant Shade
Please select from the options above:
2
Air Conditioning Window Unit Cooling Capacity
Room Name: Kitchen
Room Area (in square feet): 360.0
Room Shade: Moderate Shade
Capacity of the air conditioning unit (in BTU Per Hour): 10000.0

Press Y to enter another room or any other key to exit:
n
Total number of rooms entered: 3


Related Solutions

Churchill HVAC Inc. buys and sells heating and air-conditioning units that are used in homes across...
Churchill HVAC Inc. buys and sells heating and air-conditioning units that are used in homes across Scarborough. The company follows IFRS. Unit selling prices range from $2,250 to $15,000. Churchill sells a heating system to Drake on November 15, 2019. The selling price for the heating system is usually $13,500. - Churchill will also install the heating system. The estimated fair value of the installation is $1,500. Churchill sold the heating system with installation to Drake for $14,250. The heating...
An air-conditioning system operates at a total pressure of 1 atm and consists of a heating...
An air-conditioning system operates at a total pressure of 1 atm and consists of a heating section and an evaporative cooler. Air enters the heating section at 15°C and 55 percent relative humidity at a rate of 30 m3/min, and it leaves the evaporative cooler at 25°C and 45 percent relatively humidity. Using appropriate software, study the effect of total pressure in the range 94 to 100 kPa and plot the results as functions of total pressure. (Please upload your...
On January 2, 2019, Royal Class Air Conditioning and Heating sold and installed an HVAC system...
On January 2, 2019, Royal Class Air Conditioning and Heating sold and installed an HVAC system to Peak Co. for $2,750. The selling price is allocated as follows: (1) 90% for the HVAC unit and (2) 10% for an ongoing 4-year service contract for the HVAC unit. a. Determine each of the following related to this sale: 1. Identify the contract between the company and the customer. 2. Identify the performance obligations of Royal Class. 3. Determine the transaction price....
You have located the following information on Webb’s Heating & Air Conditioning: debt ratio is 54...
You have located the following information on Webb’s Heating & Air Conditioning: debt ratio is 54 percent, capital intensity is 1.10 times, profit margin is 12.5 percent, and the dividend payout is 25 percent. Calculate the sustainable growth rate for Webb. (Do not round intermediate calculations and round your final answer to 2 decimal places.)
Heating, Ventilating and Air Conditioning (HVAC) Systems create and maintain the levels of comfort required by...
Heating, Ventilating and Air Conditioning (HVAC) Systems create and maintain the levels of comfort required by guests and employees. HVAC systems must be properly selected, operated and maintained if they are they are to provide an appropriate level of comfort. How do you think a hotel building stays cool?
A central air conditioning unit was installed at an initial cost of $65,000 and was expected...
A central air conditioning unit was installed at an initial cost of $65,000 and was expected to have a salvage value of $5,000 after a service life of 12 years. a) What amount had accumulated in a straight-line depreciation reserve at the end of the 5th year? b) Using double declining balance depreciation, determine the book value at the end of the 9th year. c) If the equipment was sold in the 6th year for $10,000, what sunk cost would...
5. You are an air-conditioning systems designer, and you have been tasked with developing an air-conditioning...
5. You are an air-conditioning systems designer, and you have been tasked with developing an air-conditioning system (cooling only) for lecture theatre building 32 on ECU’s Joondalup Campus. As a first step you will need to develop a model of the system, explain how you would go about this by providing answers to the following: a. The steps that you would take when developing a mathematical model of the system and what information you would need b. List all of...
Rad Co. manufactures and sells heating and air conditioning systems. Rad Co is a public company.
Rad Co. manufactures and sells heating and air conditioning systems. Rad Co is a public company.   On September 1, 2021 Rad sold 20 heating systems to Heating Rental Company for $50,000 (on credit). The cost of the heating systems sold was $1,000 each. Heating Rental Company is a new customer. Rad offers a 60-day return policy. Based on past experience usually 5% of the systems will be returned.   Prepare the journal entries for September 1st.
A central air conditioning unit was installed on January 1, 2000at an initial cost of...
A central air conditioning unit was installed on January 1, 2000 at an initial cost of P650,000 and was expected to have a salvage value of P50,000 after a life of 7 years. a. What amount of depreciation had accumulated in a sum-of-the-years’-digit method at the end of 2003? b. Using the declining balance method, determine the depreciation charged for 2004 and the book value at the end of 2004. c. If the equipment was sold on Jan 1, 2005...
In an air conditioning system, the inside and outside conditions of air are 25 °C DBT...
In an air conditioning system, the inside and outside conditions of air are 25 °C DBT and 50% RH, and 40 °C DBT and 27 °C WBT, respectively. The room sensible heat ratio is 0.8, while 50% of the room air is rejected to atmosphere and replaced with an equal quantity of fresh air before entering the air conditioning apparatus. If the fresh air added is 100 m3 /min and the air density is 1.2 kg/ m3 with zero air...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT