לולאות WHILE

int count = 0, maxGrade,minGrade,currGrade,sum = 0;

double avg;

System.out.println("please insert the first grade");

currGrade = reader.nextInt();

minGrade = currGrade;

maxGrade = currGrade;

while (currGrade != -999){

     count++;

     sum += currGrade;

     if (currGrade < minGrade){

          minGrade = currGrade;

     }

     if (currGrade > maxGrade){

          maxGrade = currGrade;

     }

     System.out.println("please insert the next grade");

     currGrade = reader.nextInt();

}

System.out.println("count = "+count);

System.out.println("max = "+maxGrade);

System.out.println("min = "+minGrade);

avg = (double)sum / count;

System.out.println("avg = "+avg);