package assessment4;
import java.util.Scanner;
public class q4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the number of students :");
int numberStudent = in.nextInt();
while (numberStudent < 0) {
System.out.println("Invalid student, try again :");
Scanner sc=new Scanner(System.in);
numberStudent = sc.nextInt();
}
int[] grade = new int[numberStudent];
float sum = 0;
for (int i = 0; i < numberStudent; i++) {
System.out.println("Enter the grade for students " + (i + 1) + ": ");
int num = in.nextInt();
while (num < 0 || num > 100) {
System.out.println("Invalid grade, try again ");
num = in.nextInt();
grade[i]= num;
sum += grade[i];
}
}
System.out.println("The average is :" + sum / numberStudent);
}
}