ITEC 120 LAB 3 Back to Lab index page

Painting a Room

The file Paint.java contains a partial program, which when complete will calculate the amount of paint needed to paint the walls of a room of the given length and width. (Paint all 4 walls -- no floor or ceiling.) It assumes that the paint covers 350 square feet per gallon.

Save Paint.java to your directory and do the following:

• Fill in the missing statements (the comments tell you where to fill in) so that the program does what it is supposed to. Compile and run the program and correct any errors.
• Suppose the room has doors and windows that don't need painting. Ask the user to enter the number of doors and number of windows in the room, and adjust the total square feet to be painted accordingly. Assume that each door is 18 square feet and each window is 12 square feet.

Sample 1:

 Program outputs: What is the width of the room to be painted? User inputs: 13 Program outputs: What is the length of the room to be painted? User inputs: 15 Program outputs: What is the height of the room to be painted? User inputs: 8 Program outputs: The 13 x 15 x 8 room will require 1.28 gallon(s) of paint.

Sample 2, after windows and doors added:

 Program outputs: What is the width of the room to be painted? User inputs: 13 Program outputs: What is the length of the room to be painted? User inputs: 15 Program outputs: What is the height of the room to be painted? User inputs: 8 Program outputs: How many doors are in the room? User inputs: 1 Program outputs: How many windows are in the room? User inputs: 2 Program outputs: The 13 x 15 x 8 room with 1 door and 2 windows will require 1.16 gallon(s) of paint.