Write a program which prompts user for the number of student
Solution
StudentScoreTest.java
import java.util.Scanner;
 public class StudentScoreTest {
  
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println(\"Enter the number of students: \");
        int n = scan.nextInt();
        int grades[] = new int[n];
        int sumScore = 0;
        for(int i=0; i<grades.length; i++){
            System.out.println(\"Enter the grade for the student \"+(i+1)+\": \");
            grades[i] = scan.nextInt();
            if(grades[i] < 0 || grades[i] > 100){
                System.out.println(\"Invalid grade, try again...\");
                i--;
            }
        }
        for(int i=0; i<grades.length; i++){
            sumScore = sumScore + grades[i];
        }
        double average = sumScore/(double)grades.length;
        System.out.println(\"The average is \"+average);
    }
}
Output:
Enter the number of students:
 3
 Enter the grade for the student 1:
 55
 Enter the grade for the student 2:
 108
 Invalid grade, try again...
 Enter the grade for the student 2:
 56
 Enter the grade for the student 3:
 57
 The average is 56.0

