Write a code that reads a list of student grades from standard input line-by-line until there are no more lines to read or an empty line is encountered.
However, I cannot exit the loop anyway. I tried to write
Scanner input = new Scanner(input.hasNext()); and else break but it is not working
public class NumInput {
  public static void main(String [] args) {
    float min = Float.MAX_VALUE;
    float max = Float.MIN_VALUE;
    float total=0;
    int count=0;
    Scanner input = new Scanner(System.in);
    while (input.hasNext()) {
      float val = input.nextFloat();
      if (val < min) {
          min = val;
      }
      if (val > max) {
         max = val;
      }
      count++; 
      total += val ;
    }
    float average = (float) total / count;
    System.out.println("min: " + min);
    System.out.println("max: " + max);
    System.out.println("The Average value is: " + average);
  }
}
 
     
    