Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //***************************************************************
- //File: Paint.java
- //
- //Purpose: Determine how much paint is needed to paint the walls
- //of a room given its length, width, and height
- //***************************************************************
- import java.util.Scanner;
- public class Paint
- {
- public static void main(String[] args)
- {
- final int COVERAGE = 350; //paint covers 350 sq ft/gal
- final int DOOR_AREA = 20;
- final int WINDOW_AREA = 15;
- //declare integers length, width, and height;
- int length;
- int width;
- int height;
- int numDoors, numWindows;
- //declare double totalSqFt;
- double totalSqFt;
- //declare double paintNeeded;
- double paintNeeded;
- //declare and initialize Scanner object
- Scanner input = new Scanner(System.in);
- //Prompt for and read in the length of the room
- System.out.println("Enter the length of the room: ");
- length = input.nextInt();
- //Prompt for and read in the width of the room
- System.out.println("Enter the width of the room: ");
- width = input.nextInt();
- //Prompt for and read in the height of the room
- System.out.println("Enter the height of the room: ");
- height = input.nextInt();
- System.out.println("How many doors are in the room: ");
- numDoors = input.nextInt();
- System.out.print ("How many windows are in the room: ");
- numWindows = input.nextInt();
- totalSqFt = 2 * width * height + 2 * length * height;
- totalSqFt = totalSqFt - numDoors * DOOR_AREA - numWindows * WINDOW_AREA;
- paintNeeded = totalSqFt / COVERAGE;
- //Compute the total square feet to be painted--think
- //about the dimensions of each wall
- System.out.println();
- System.out.println(paintNeeded + " gallons of paint are needed to " + "paint a room " + width + " feet wide by ");
- //Compute the amount of paint needed
- System.out.println(length + " feet long by " + height + " feet high with " + numDoors + " doors and " + numWindows + " windows.");
- //Print the length, width, and height of the room and the
- //number of gallons of paint needed.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement