Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Paint {
- public static void main(String[] args) {
- //declare and initialize Scanner object
- Scanner scan=new Scanner(System.in);
- //Constants are variables that use the final modifier. They cannot be changed once they are initialized
- final int COVERAGE = 350; //paint covers 350 sq ft/gal
- final int WINDOW_SQ_FT=10;
- final int DOOR_SQ_FT=20;
- //declare integers length, width, and height;
- int length=0, width=0, height=0;
- //declare intefers numWindows, numDoors
- int numWindows, numDoors;
- //declare integers totalWindowSqFt, totalDoorSqFt
- int totalWinSqFt, totalDoorSqFt;
- //declare double totalSqFt;
- int totalSqFt;
- //declare double paintNeeded;
- double paintNeeded;
- //inputs below!++++++++++++++++++++++++++++++++++++++++++++
- //Prompt for and read in the length of the room
- System.out.println("Please enter the length of the room.");
- length=scan.nextInt();
- //Prompt for and read in the width of the room
- System.out.println("Please enter the width of the room.");
- width=scan.nextInt();
- //Prompt for and read in the height of the room
- System.out.println("Please enter the height of the room.");
- height=scan.nextInt();
- //Prompt for and read in the number of windows
- System.out.println("Please enter the number of windows in the room.");
- numWindows=scan.nextInt();
- //Prompt for and read in the number of doors
- System.out.println("Please enter the number of doors in the room.");
- numDoors=scan.nextInt();
- //CALCULATIONS BELOW++++++++++++++++++++++++++++++++++++++++++
- //Compute the total square feet to be painted--think
- //about the dimensions of each wall minus the footage for windows and doors
- totalSqFt=(length*height*2)+(width*height*2);
- totalWinSqFt=numWindows*WINDOW_SQ_FT;
- totalDoorSqFt=numDoors*DOOR_SQ_FT;
- totalSqFt=totalSqFt-(totalWinSqFt+totalDoorSqFt);
- //Compute the amount of paint needed
- paintNeeded=(double)totalSqFt/COVERAGE;
- //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("Total Surface Area: "+totalSqFt+"\nNumber of Doors: "+numDoors+"\nNumber of Windows: "+numWindows);
- System.out.println("Paint needed: "+paintNeeded+"\ngallons: ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment