This is a simple paint calculator program I built. I am an absolute beginner and I am having problems returning and displaying methods to the main. I keep trying to call the paintFormula() method back to the main but I keep getting errors. Also I am not sure if I am passing the wallArea() methods "calculated wallArea" to the paintFormula(). I keep trying but nothing works.
The instructions ask me to:
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:
* Calculates the wall area for a room
* Passes the calculated wall area to another method that calculates and returns the number of gallons of paint needed
* Displays the number of gallons needed
* Computes the price based on a paint price of $32 per gallon, assuming that the painter can buy any fraction of a gallon of paint at the same
price as a whole gallon.
* Returns the price to the main() method
* The main() method displays the final price.
import java.util.Scanner; public class PaintCalculator2 { public static void main(String [] args) { Scanner keyboard = new Scanner(System.in); double wallArea; double height; double length; double width; double price; double WallArea; double paintQuantity; //Prompts user for the dimensions of the room System.out.print("Please enter the height of the room: "); height = keyboard.nextDouble(); System.out.print("Please enter the length of the room: "); length = keyboard.nextDouble(); System.out.print("Please enter the width of the room: "); width = keyboard.nextDouble(); WallAreaMethod(height, length, width); } //Calulates the area of the wall in a room public static double WallAreaMethod(double height, double length, double width) { double wallArea; wallArea = length * height * width * height; return wallArea; } //Computes the quanity of paint needed public static double paintFormula(double wallAreaMethod, double price, double height, double length,double width) { double wallArea; double paintQuantity; paintQuantity = wallAreaMethod * 2 / 350; System.out.println("For a room of height " + height + "feet, length " + length + " feet, and width " + width + " feet you need to purchase " + paintQuantity + " gallons of paint."); System.out.println("The price will be $" + price + "."); price = paintQuantity * 32.0; return price; } }