Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. // project 2
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Project2_R_B {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Scanner keyboard = new Scanner(System.in);
  10.  
  11. System.out.print("Please enter the name of the room: "); // step 1
  12. String room = keyboard.nextLine(); // user input for the name of the room
  13.  
  14. // Add input validation to the code
  15.  
  16. System.out.print("Please enter the length of the room (in feet): ");
  17. double length = keyboard.nextDouble(); // variable for length
  18. while (length < 5 && ) { // step 2
  19. System.out.println("Length of the " + room + " may not be less than 5 feet.");
  20. System.out.print("Please enter the length of the room (in feet): ");
  21. length = keyboard.nextDouble();
  22. }
  23.  
  24. System.out.print("Please enter the width of the room (in feet): ");
  25. double width = keyboard.nextDouble(); // variable for width
  26. while (width < 5) {
  27. System.out.println("Width of the " + room + " may not be less than 5 feet.");
  28. System.out.print("Please enter the width of the room (in feet): ");
  29. width = keyboard.nextDouble();
  30. }
  31.  
  32. double area = 0.0; // variable initialization for area
  33.  
  34. area = length * width;
  35.  
  36. System.out.println("What is the amount of shade that this room receives?");
  37. System.out.println();
  38. System.out.println(" 1. Little Shade");
  39. System.out.println(" 2. Moderate Shade");
  40. System.out.println(" 3. Abundant Shade");
  41. System.out.println();
  42. System.out.print("Please select from the options above: ");
  43. int option = keyboard.nextInt();
  44.  
  45. double btuCap = 0.0; // variable for Air Conditioner Capacity (BTU's per hour)
  46.  
  47. if (area < 250) {
  48. btuCap = 5500;
  49. }
  50. else if (area >= 250 && area <= 500) {
  51. btuCap = 10000;
  52. }
  53. else if (area > 500 && area < 1000) {
  54. btuCap = 17500;
  55. }
  56. else {
  57. btuCap = 24000;
  58. }
  59.  
  60. double btuShade = 0.0; // variable for increase or decrease of BTU capacity
  61.  
  62. String shade = "shade";
  63.  
  64. if (option == 1) {
  65. btuShade = 0.15;
  66. shade = "Little";
  67. }
  68. else if (option == 2) {
  69. shade = "Moderate";
  70. }
  71. else {
  72. btuShade = -0.10;
  73. shade = "Abundant";
  74. }
  75.  
  76. btuCap += btuCap * btuShade;
  77.  
  78. System.out.println();
  79. String s1 = "Air Conditioning Window Unit Cooling Capacity";
  80. System.out.println(s1);
  81.  
  82. System.out.println();
  83. System.out.println("Room Area (in square feet): " + area);
  84.  
  85. System.out.println("Amount of Shade: " + shade);
  86.  
  87. System.out.printf("BTU's Per Hour needed: %,.0f\n", btuCap);
  88.  
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement