Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. //***************************************************************
  2. //File: Paint.java
  3. //
  4. //Purpose: Determine how much paint is needed to paint the walls
  5. //of a room given its length, width, and height
  6. //***************************************************************
  7. import java.util.Scanner;
  8.  
  9. public class Paint
  10. {
  11. public static void main(String[] args)
  12. {
  13. final int COVERAGE = 350; //paint covers 350 sq ft/gal
  14. final int DOOR_AREA = 20;
  15. final int WINDOW_AREA = 15;
  16.  
  17. //declare integers length, width, and height;
  18. int length;
  19. int width;
  20. int height;
  21.  
  22. int numDoors, numWindows;
  23.  
  24. //declare double totalSqFt;
  25. double totalSqFt;
  26.  
  27. //declare double paintNeeded;
  28. double paintNeeded;
  29.  
  30. //declare and initialize Scanner object
  31. Scanner input = new Scanner(System.in);
  32.  
  33. //Prompt for and read in the length of the room
  34. System.out.println("Enter the length of the room: ");
  35. length = input.nextInt();
  36.  
  37. //Prompt for and read in the width of the room
  38. System.out.println("Enter the width of the room: ");
  39. width = input.nextInt();
  40.  
  41. //Prompt for and read in the height of the room
  42. System.out.println("Enter the height of the room: ");
  43. height = input.nextInt();
  44.  
  45. System.out.println("How many doors are in the room: ");
  46. numDoors = input.nextInt();
  47.  
  48. System.out.print ("How many windows are in the room: ");
  49. numWindows = input.nextInt();
  50.  
  51.  
  52. totalSqFt = 2 * width * height + 2 * length * height;
  53. totalSqFt = totalSqFt - numDoors * DOOR_AREA - numWindows * WINDOW_AREA;
  54. paintNeeded = totalSqFt / COVERAGE;
  55.  
  56. //Compute the total square feet to be painted--think
  57. //about the dimensions of each wall
  58. System.out.println();
  59. System.out.println(paintNeeded + " gallons of paint are needed to " + "paint a room " + width + " feet wide by ");
  60.  
  61. //Compute the amount of paint needed
  62. System.out.println(length + " feet long by " + height + " feet high with " + numDoors + " doors and " + numWindows + " windows.");
  63.  
  64. //Print the length, width, and height of the room and the
  65. //number of gallons of paint needed.
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement