#I'm at the class making GradeComputation in Netbeans

4 messages · Page 1 of 1 (latest)

winged mortar
#

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

pallid groveBOT
#

This post has been reserved for your question.

Hey @winged mortar! Please use /close or the Close 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.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

pallid groveBOT