Help- super stumped on my loop...
I need to create a loop so the amount that you input for example 5 students inputted, will corrospond to a grade. I have done the code, I just don't understand how I can get the input to corrospond to the grades. Here is what I have so far:
public class practise {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int i = 0;
int sum = 0;
System.out.println("Enter the number of students: ");
int students = in.nextInt();
System.out.println("Enter exam score of each student:");
int score = in.nextInt();
for (; students < score; students++) {
int n = in.nextInt();
sum+=n;
if (n >= 41) {
System.out.println("Invalid exam scores, reenter: ");
}
}
if (score <= 40 && score >= 36 ) {
System.out.println("Grade Score: 5");
} if (score <= 35 && score >= 30) {
System.out.println("Grade Score: 4");
} if (score <= 29 && score >= 20) {
System.out.println("Grade Score: 3");
} if (score <= 19 && score >= 0 ) {
System.out.println("Grade Score: U");
}
}
}
What is it that I need to do to get this to work?