Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So im new to Java and have absolutelely no i dea how to do this HW exercise, i k

ID: 3671567 • Letter: S

Question

So im new to Java and have absolutelely no i dea how to do this HW exercise, i keep getting outrageous answers like 7.3 when the length is 10, width is 10, and height is 8.

Painting a Room

File Paint.java contains the partial program below, which when complete will calculate the amount of paint needed to paint

the walls of a room of the given length and width. It assumes that the paint covers 350 square feet per gallon.

//***************************************************************

//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

//declare integers length, width, and height;

//declare double totalSqFt;

//declare double paintNeeded;

//declare and initialize Scanner object

//Prompt for and read in the length of the room

//Prompt for and read in the width of the room

//Prompt for and read in the height of the room

//Compute the total square feet to be painted--think

//about the dimensions of each wall

//Compute the amount of paint needed

//Print the length, width, and height of the room and the

//number of gallons of paint needed.

Explanation / Answer

import java.util.Scanner;
public class Paint
{
public static void main(String[] args)
{
final int COVERAGE = 350; //paint covers 350 sq ft/gal
//declare integers length, width, and height;
int length,width,height;
//declare double totalSqFt;
double totalSqFt;
//declare double paintNeeded;
double paintNeeded;
//declare and initialize Scanner object
Scanner scan = new Scanner(System.in);
//Prompt for and read in the length of the room
System.out.println("Input total length");
length = scan.nextInt();
//Prompt for and read in the width of the room
System.out.println("Input total width");
width = scan.nextInt();
//Prompt for and read in the height of the room
System.out.println("Input total height");
height = scan.nextInt();
// Doors and windows
System.out.println("How many windows do you have: ");
int windows = scan.nextInt();
System.out.println("How many doors do you have: ");
int doors = scan.nextInt();
scan.close();
//Compute the total square feet to be painted--think
totalSqFt = length * width * height;
//about the dimensions of each wall
//Compute the amount of paint needed
doors *= 20;
windows *= 15;
totalSqFt -= doors;
totalSqFt -= windows;
paintNeeded = totalSqFt / COVERAGE;
//Print the length, width, and height of the room and the
System.out.println("The length of the room is: " + length);
System.out.println("The width of the room is: " + width);
System.out.println("The height of the room is: " + height);
System.out.println("The total square feet is: " + totalSqFt);
//number of gallons of paint needed.
System.out.println("The number of gallons of paint needed is: " + paintNeeded);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote