I am new to Java and just started.
This is my current code:
public class MathWork {
public static void main(String[]args) {
System.out.println("Enter 3 numbers below for A, B and C");
Scanner input = new Scanner(System.in);
System.out.println("Enter A: ");
double a;input.nextDouble();
System.out.println("Enter B: ");
double b;input.nextDouble();
System.out.println("Enter C: ");
double c;input.nextDouble();
System.out.println("X = "+(a+b+c));
System.out.println("Fuel = ");
System.out.println("Mean = ");
System.out.println("Aint = ");
System.out.println("geo = ");
input.close();
}
}
When I try to run this an error appears for the print statement for X saying that "The local variable a may not have been initialized" but for all three variables. The variables are supposed to be equal to what numbers are inputed so I don't really know how to fix this.
Also yes, I have import java.util.Scanner; at the top.