I need to write a program that receives 3 random values and allocates the 3 values to 3 variables MINOR, MIDDLE, and GREATER. I tried something like this, but at the time of printing the values, I get the error that var A B C were not initialized.
Error:
variable A might not have been initialized
variable B might not have been initialized
variable C might not have been initialized
Code:
int A,B,C;
System.out.println("Digite 3 valores!");
int vala = input.nextInt();
int valb = input.nextInt();
int valc = input.nextInt();
if (vala > valb && vala > valc) { A = vala;}
else if (valb > vala && valb > valc) { A = valb;}
else if (valc > vala && valc > valc) { A = valc;}
else if (vala < valb && vala < valc) { B = vala;}
else if (valb < vala && valb < valc) { B = valb;}
else if (valc < vala && valc < valb) { B = valc;}
else if (vala > valb && vala < valc || vala < valb && vala > valc) { C = vala;}
else if (valb > vala && valb < valc || valb < vala && valb > valc) { C = valb;}
else if (valc > vala && valc < valb || valc < vala && valc > valb) { C = valc;}
System.out.println(A);
System.out.println(B);
System.out.println(C);