虚言NEUROSE
JCHJava Community | Help. Code. Learn.
•Created by 虚言NEUROSE on 11/5/2024 in #java-help
I'm at the class making GradeComputation in Netbeans
and I am so confused about this code right now
import java.util.Scanner;
public class GradeComputation {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of students: ");
int numberOfStudents = scanner.nextInt();
// Array to hold student scores
int[] scores = new int[numberOfStudents];
//Collect scores from user
for (int i = 0; i < numberOfStudents; i++) {
System.out.print("Enter score for student " + (i + 1) + ": ");
scores[i] = scanner.nextInt();
}
// Compute and displaay grades
System.out.println("\nStudent Grades:");
for (int i = 0; i < numberOfStudents; i++) {
char grade;
if (scores[i] >= 90) {
System.out.println ("Excellent");
} else if (scores[i] >= 80) {
System.out.println("Perfect");
} else if (scores[i] >= 70) {
System.out.println("Not Bad");
} else if (scores[i] >= 60) {
System.out.println("What Happened");
} else {
System.out.println("oh no");
}
System.out.println("Student" + (1 + 1) + ": Scores " "Scores " scores[i] + "Grade =" + grade);
}
scanner.close();
}
}
Total error: 31
5 replies