SHARE
TWEET

Untitled

a guest Feb 26th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // project 2
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Project2_Ryan_Blouin {
  6.  
  7.    public static void main(String[] args) {
  8.      
  9.       Scanner keyboard = new Scanner(System.in);
  10.      
  11.       String anotherRoom = ""; // string for the while for new room
  12.       int numberOfRooms = 0; // variable that will be incremented by 1 each time a user inputs a new room.
  13.      
  14.       do {
  15.      
  16.          System.out.print("Please enter the name of the room: "); // step 1
  17.          String room = keyboard.nextLine(); // user input for the name of the room
  18.          ++numberOfRooms;
  19.      
  20.       // Add input validation to the code
  21.      
  22.          System.out.print("Please enter the length of the room (in feet): ");
  23.          double length = keyboard.nextDouble(); // variable for length
  24.      
  25.          while (length < 5) { // step 2
  26.             System.out.println("Length of the " + room + " may not be less than 5 feet.");
  27.             System.out.print("Please enter the length of the room (in feet): ");
  28.             length = keyboard.nextDouble();
  29.          }
  30.        
  31.          System.out.print("Please enter the width of the room (in feet): ");
  32.          double width = keyboard.nextDouble(); // variable for width
  33.      
  34.          while (width < 5) {
  35.             System.out.println("Width of the " + room + " may not be less than 5 feet.");
  36.             System.out.print("Please enter the width of the room (in feet): ");
  37.             width = keyboard.nextDouble();
  38.          }
  39.      
  40.          double area = 0.0; // variable initialization for area
  41.      
  42.          area = length * width;
  43.      
  44.          System.out.println("What is the amount of shade that this room receives?");  
  45.          System.out.println();
  46.          System.out.println("      1. Little Shade");
  47.          System.out.println("      2. Moderate Shade");
  48.          System.out.println("      3. Abundant Shade");
  49.          System.out.println();
  50.          System.out.print("Please select from the options above: ");
  51.          int option = keyboard.nextInt();
  52.          
  53.          while (option < 1 || option > 3) {
  54.             System.out.print("Please select from the options above: ");
  55.             option = keyboard.nextInt();
  56.          }
  57.      
  58.          double btuCap = 0.0; // variable for Air Conditioner Capacity (BTU's per hour)
  59.      
  60.          if (area < 250) {
  61.             btuCap = 5500;
  62.          }
  63.          else if (area >= 250 && area <= 500) {
  64.             btuCap = 10000;
  65.          }
  66.          else if (area > 500 && area < 1000) {
  67.             btuCap = 17500;
  68.          }
  69.          else {
  70.             btuCap = 24000;
  71.          }
  72.          
  73.          double btuShade = 0.0; // variable for increase or decrease of BTU capacity
  74.      
  75.          String shade = "shade";
  76.          
  77.          if (option == 1) {
  78.             btuShade = 0.15;
  79.             shade = "Little";
  80.          }
  81.          else if (option == 2) {
  82.             shade = "Moderate";
  83.          }
  84.          else {
  85.             btuShade = -0.10;
  86.             shade = "Abundant";
  87.          }
  88.      
  89.          btuCap += btuCap * btuShade;
  90.      
  91.          System.out.println();
  92.          String s1 = "Air Conditioning Window Unit Cooling Capacity";
  93.          System.out.println(s1);
  94.          System.out.println("Room Name: " + room);
  95.          System.out.println("Room Area (in square feet): " + area);
  96.          System.out.println("Amount of Shade: " + shade);
  97.          System.out.printf("BTU's Per Hour needed: %,.0f\n", btuCap);
  98.          System.out.println();
  99.      
  100.          System.out.print("Would you like to enter information for another room (Y/N)? "); // step 3
  101.          keyboard.nextLine();  
  102.          anotherRoom = keyboard.nextLine();
  103.          System.out.println();
  104.      
  105.       }
  106.       while (anotherRoom.equalsIgnoreCase("Y"));
  107.       System.out.println();
  108.      
  109.       System.out.println("The total number of rooms processed was: " + numberOfRooms);  // step 4
  110.    }
  111. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top