i keep on getting the same error again.
i was wondering if someone could kindly take the time to look over this simple error, please.
it says:
: variable i might not have been initialized
while(i<=5)
^
1 error
Process completed.
my program is:
import java.lang.String; import java.util.Scanner; public class WeCanWorkItOut { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Please enter a number"); double num1=input.nextDouble(); System.out.println("Please enter a second number"); double num2=input.nextDouble(); System.out.println("Please enter a third number"); double num3=input.nextDouble(); System.out.println("Please enter a fourth number"); double num4=input.nextDouble(); System.out.println("Please enter a fifth and final number"); double num5=input.nextDouble(); if(num1<num2) if(num2<num3) if(num3<num4) if(num4<num5) { System.out.println(" The first number entered is the smallest number. "); } else { System.out.println(" Some of the numbers might be incorrect. " + " Enter other numbers. "); } if(num1>num2) if(num2>num3) if(num3>num4) if(num4>num5) { System.out.println(" The first number entered is the largest number. "); } else { System.out.println(" Some of the numbers might be equal. "); } if(num1<=num2) if(num2<=num3) if(num3<=num4) if(num4<=num5) { System.out.println(" There isn't a number with the lowest value as some or all of these numbers may be equal. "); } else { System.out.println(" Try entering other numbers. "); } // indefinite= greater than or equal to // if(num1>=num2) if(num2>=num3) if(num3>=num4) if(num4>=num5) { System.out.println(" There isn't a number with the highest value as some or all of the values may be equal. "); } else { System.out.println(" Try entering other numbers. "); } double average; average= (num1+num2+num3+num4+num5)/5; System.out.println ("Average:"+average); int largest=Integer.MIN_VALUE; int smallest=Integer.MAX_VALUE; int compared=0; int i; Scanner scan=new Scanner(System.in); while(i<=5) { System.out.println ("Please enter a value."); compared=scan.nextInt(); if(compared>largest) { largest=compared; } if(compared<smallest) { smallest=compared; } i++; } System.out.println (smallest); System.out.println (largest); } }