cgorrillaha

Paint a Room

Sep 15th, 2021
843
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class Paint {
  3.  
  4.     public static void main(String[] args) {
  5.  
  6.         //declare and initialize Scanner object
  7.         Scanner scan=new Scanner(System.in);
  8.  
  9.         //Constants are variables that use the final modifier.  They cannot be changed once they are initialized
  10.         final int COVERAGE = 350;  //paint covers 350 sq ft/gal
  11.         final int WINDOW_SQ_FT=10;
  12.         final int DOOR_SQ_FT=20;
  13.         //declare integers length, width, and height;
  14.         int length=0, width=0, height=0;
  15.         //declare intefers numWindows, numDoors
  16.         int numWindows, numDoors;
  17.         //declare integers totalWindowSqFt, totalDoorSqFt
  18.         int totalWinSqFt, totalDoorSqFt;
  19.         //declare double totalSqFt;
  20.         int totalSqFt;
  21.         //declare double paintNeeded;
  22.         double paintNeeded;
  23.  
  24.  
  25.         //inputs below!++++++++++++++++++++++++++++++++++++++++++++
  26.         //Prompt for and read in the length of the room
  27.         System.out.println("Please enter the length of the room.");
  28.         length=scan.nextInt();
  29.  
  30.         //Prompt for and read in the width of the room
  31.         System.out.println("Please enter the width of the room.");
  32.         width=scan.nextInt();
  33.  
  34.         //Prompt for and read in the height of the room
  35.         System.out.println("Please enter the height of the room.");
  36.         height=scan.nextInt();
  37.  
  38.         //Prompt for and read in the number of windows
  39.         System.out.println("Please enter the number of windows in the room.");
  40.         numWindows=scan.nextInt();
  41.  
  42.         //Prompt for and read in the number of doors
  43.         System.out.println("Please enter the number of doors in the room.");
  44.         numDoors=scan.nextInt();
  45.  
  46.         //CALCULATIONS BELOW++++++++++++++++++++++++++++++++++++++++++
  47.         //Compute the total square feet to be painted--think
  48.         //about the dimensions of each wall minus the footage for windows and doors
  49.         totalSqFt=(length*height*2)+(width*height*2);
  50.         totalWinSqFt=numWindows*WINDOW_SQ_FT;
  51.         totalDoorSqFt=numDoors*DOOR_SQ_FT;
  52.  
  53.         totalSqFt=totalSqFt-(totalWinSqFt+totalDoorSqFt);
  54.  
  55.         //Compute the amount of paint needed
  56.         paintNeeded=(double)totalSqFt/COVERAGE;
  57.         //Print the length, width, and height of the room and the
  58.         //number of gallons of paint needed.
  59.         System.out.println("Length: "+length+"\nWidth: "+width+"\nHeight: "+height);
  60.         System.out.println("Total Surface Area: "+totalSqFt+"\nNumber of Doors: "+numDoors+"\nNumber of Windows: "+numWindows);
  61.         System.out.println("Paint needed: "+paintNeeded+"\ngallons: ");
  62.  
  63.     }
  64.  
  65. }
  66.  
RAW Paste Data