Getting a not initialised error for my area calculation program. I need for it to stay as double not int so it will be able to accept decimal numbers. Here is the error. AreaCalculationProgram.java:39: error: variable width might not have been initialized areaofrectangle = width * length;
And here is my code:
//Code for Rectangle
double areaofrectangle, width, length;
//int areaofrectangle;
System.out.print(" --> Enter Width of Rectangle in Centimetres: ");
//Scanner sc = new Scanner(System.in); //Scanner is for testing rectangle by its self
//int width = sc.nextInt();
// double width = sc.nextDouble();
System.out.print(" --> Enter Length of Rectangle in Centimetres: ");
//int length = sc.nextInt();
// double length = sc.nextDouble();
areaofrectangle = width * length;
System.out.print("Area of Rectangle: "+ areaofrectangle);
Thanks