In: Computer Science
I know that there are several different answers that has already been posted for this. I have tried all of the options but wanted to see if I can get a correct one that actually works.
Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following:
The main() method displays the final price. For example:
You will need 2.0 gallons The price to paint the room is $64.0
Grading
Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade.
Once you are happy with your results, click the Submit button to record your score.
14
1
import java.util.Scanner;
2
public class PaintCalculator {
3
public static void main (String args[]) {
4
// Write your code here
5
}
6
7
public static double computeArea(double length, double width, double height) {
8
// Write your code here
9
}
10
public static double computeGallons(double area) {
11
// Write your code here
12
}
13
}
14
Please, please please help! I've been working on this problem for a week now.
import java.util.Scanner; public class PaintCalculator { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.print("Enter length: "); double length = in.nextDouble(); System.out.print("Enter width: "); double width = in.nextDouble(); System.out.print("Enter height: "); double height = in.nextDouble(); double area = computeArea(length, width, height); double gallons = computeGallons(area); System.out.println("You will need " + gallons + " gallons"); System.out.println("The price to paint the room is $" + (32 * gallons)); in.close(); } public static double computeArea(double length, double width, double height) { return 2*(length*width + length*height + height*width); } public static double computeGallons(double area) { return Math.ceil(area / 350); } }