Hello I am an absolute begginer and am working on a paint calulator program. I am trying to return the price from the paintformula ex: price = paintFormula(wallArea,price,height,length,width); or paintFormula(wallArea,price,height,length,width);. When I call the method I keep getting errors like: PaintCalculator2.java:33: error: variable price might not have been initialized.
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();
wallArea = wallAreaMethod(height, length, width);
System.out.println("So the wall area is " + wallArea + "ft.");
price = paintFormula(wallArea,price,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 = 2*length*height + 2*width*height;
return wallArea;
}
//Computes the quanity of paint needed
public static double paintFormula(double areaMethod, double price, double height, double length, double width)
{
areaMethod = wallAreaMethod(height, length, width);
double paintQuantity;
paintQuantity = areaMethod * 2 / 350;
price = paintQuantity * 32.0;
return price;
}
}