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
3 Replies
β
This post has been reserved for your question.
Hey @D.ie.ayne! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Please format your code to make it more readable. For java, it should look like this:
π€
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.