Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- /* DECLARATIONS++++++++++++++++++++++++++++++++++++++ */
- final int COVERAGE = 350, WINDOW_AREA = 15, DOOR_AREA = 20; // paint covers 350 sq ft/gal
- // declare integers length, width, and height;
- int length, width, height;
- int numWindows, numDoors;
- // declare double totalSqFt;
- double totalSqFt;
- double windowDoorTotalArea;
- // declare double paintNeeded;
- double paintNeeded;
- // declare and initialize Scanner object
- Scanner scan = new Scanner(System.in);
- /* inputs+++++++++++++++++++++++++++++++++++++++++++++++++++ */
- // Prompt for and read in the length of the room
- System.out.println("Please enter the length: ");
- length = scan.nextInt();
- // Prompt for and read in the width of the room
- System.out.println("Please enter the width: ");
- width = scan.nextInt();
- // Prompt for and read in the height of the room
- System.out.println("Please enter the height: ");
- height = scan.nextInt();
- System.out.println("Please enter the number of doors: ");
- numDoors = scan.nextInt();
- System.out.println("Please enter the number of windows: ");
- numWindows = scan.nextInt();
- /* Calculations++++++++++++++++++++++++++++++++++++++++++++ */
- // Compute the total square feet to be painted--think
- // about the dimensions of each wall
- windowDoorTotalArea=(numWindows*WINDOW_AREA)+(numDoors*DOOR_AREA);
- totalSqFt = ((length * height * 2) + (width * height * 2))-windowDoorTotalArea;
- // Compute the amount of paint needed
- paintNeeded = totalSqFt / COVERAGE;
- /* Outputs+++++++++++++++++++++++++++++++++++++++++++++++++ */
- // Print the length, width, and height of the room and the
- // number of gallons of paint needed.
- System.out.println("Length: " + length + "\nWidth: " + width + "\nHeight:" + height);
- System.out.println("Number of Windows: " + numWindows + "\nNumber of Doors: " + numDoors + "\nHeight:" + height);
- System.out.println("Total square feet: " + totalSqFt);
- System.out.println("Paint needed: " + paintNeeded);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement