Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // project 2
- import java.util.Scanner;
- public class Project2_R_B {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.print("Please enter the name of the room: "); // step 1
- String room = keyboard.nextLine(); // user input for the name of the room
- // Add input validation to the code
- System.out.print("Please enter the length of the room (in feet): ");
- double length = keyboard.nextDouble(); // variable for length
- while (length < 5 && ) { // step 2
- System.out.println("Length of the " + room + " may not be less than 5 feet.");
- System.out.print("Please enter the length of the room (in feet): ");
- length = keyboard.nextDouble();
- }
- System.out.print("Please enter the width of the room (in feet): ");
- double width = keyboard.nextDouble(); // variable for width
- while (width < 5) {
- System.out.println("Width of the " + room + " may not be less than 5 feet.");
- System.out.print("Please enter the width of the room (in feet): ");
- width = keyboard.nextDouble();
- }
- double area = 0.0; // variable initialization for area
- area = length * width;
- System.out.println("What is the amount of shade that this room receives?");
- System.out.println();
- System.out.println(" 1. Little Shade");
- System.out.println(" 2. Moderate Shade");
- System.out.println(" 3. Abundant Shade");
- System.out.println();
- System.out.print("Please select from the options above: ");
- int option = keyboard.nextInt();
- double btuCap = 0.0; // variable for Air Conditioner Capacity (BTU's per hour)
- if (area < 250) {
- btuCap = 5500;
- }
- else if (area >= 250 && area <= 500) {
- btuCap = 10000;
- }
- else if (area > 500 && area < 1000) {
- btuCap = 17500;
- }
- else {
- btuCap = 24000;
- }
- double btuShade = 0.0; // variable for increase or decrease of BTU capacity
- String shade = "shade";
- if (option == 1) {
- btuShade = 0.15;
- shade = "Little";
- }
- else if (option == 2) {
- shade = "Moderate";
- }
- else {
- btuShade = -0.10;
- shade = "Abundant";
- }
- btuCap += btuCap * btuShade;
- System.out.println();
- String s1 = "Air Conditioning Window Unit Cooling Capacity";
- System.out.println(s1);
- System.out.println();
- System.out.println("Room Area (in square feet): " + area);
- System.out.println("Amount of Shade: " + shade);
- System.out.printf("BTU's Per Hour needed: %,.0f\n", btuCap);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement