Advertisement
cgorrillaha

Intro Java Painting Complete

Oct 5th, 2020 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. import java.util.Scanner;
  2. class Main {
  3.   public static void main(String[] args) {
  4.  
  5.     /* DECLARATIONS++++++++++++++++++++++++++++++++++++++ */
  6.     final int COVERAGE = 350, WINDOW_AREA = 15, DOOR_AREA = 20; // paint covers 350 sq ft/gal
  7.     // declare integers length, width, and height;
  8.     int length, width, height;
  9.     int numWindows, numDoors;
  10.     // declare double totalSqFt;
  11.     double totalSqFt;
  12.     double windowDoorTotalArea;
  13.     // declare double paintNeeded;
  14.     double paintNeeded;
  15.     // declare and initialize Scanner object
  16.     Scanner scan = new Scanner(System.in);
  17.  
  18.     /* inputs+++++++++++++++++++++++++++++++++++++++++++++++++++ */
  19.     // Prompt for and read in the length of the room
  20.     System.out.println("Please enter the length: ");
  21.     length = scan.nextInt();
  22.     // Prompt for and read in the width of the room
  23.     System.out.println("Please enter the width: ");
  24.     width = scan.nextInt();
  25.     // Prompt for and read in the height of the room
  26.     System.out.println("Please enter the height: ");
  27.     height = scan.nextInt();
  28.  
  29.     System.out.println("Please enter the number of doors: ");
  30.     numDoors = scan.nextInt();
  31.  
  32.     System.out.println("Please enter the number of windows: ");
  33.     numWindows = scan.nextInt();
  34.  
  35.     /* Calculations++++++++++++++++++++++++++++++++++++++++++++ */
  36.     // Compute the total square feet to be painted--think
  37.     // about the dimensions of each wall
  38.     windowDoorTotalArea=(numWindows*WINDOW_AREA)+(numDoors*DOOR_AREA);
  39.     totalSqFt = ((length * height * 2) + (width * height * 2))-windowDoorTotalArea;
  40.     // Compute the amount of paint needed
  41.     paintNeeded = totalSqFt / COVERAGE;
  42.  
  43.     /* Outputs+++++++++++++++++++++++++++++++++++++++++++++++++ */
  44.     // Print the length, width, and height of the room and the
  45.     // number of gallons of paint needed.
  46.     System.out.println("Length: " + length + "\nWidth: " + width + "\nHeight:" + height);
  47.     System.out.println("Number of Windows: " + numWindows + "\nNumber of Doors: " + numDoors + "\nHeight:" + height);
  48.     System.out.println("Total square feet: " + totalSqFt);
  49.     System.out.println("Paint needed: " + paintNeeded);
  50.  
  51.    
  52.  
  53.   }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement