On the Optimization of if-else in Java

problem description

this is a relatively simple topic that can be written. What I want to ask is whether these if-else can be optimized

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

public static void main (String [] args) {

    Scanner input = new Scanner(System.in);
    System.out.println("Enter the number of students:");
    int n = input.nextInt();
    int[] score = new int[n];
    System.out.println("Enter scores:");

    int max = 0;
    for (int i = 0; i < n; iPP) {
        score[i] = input.nextInt();
        if (score[i] > max) {
            max = score[i];
        }
    }

    for (int i = 0; i < n; iPP) {
        if (score[i] >= max - 10)
            System.out.println("Student " + i + " score is " + score[i] + " and grade is A");
        else if (score[i] >= max - 20 && score[i] < max - 10)
            System.out.println("Student " + i + " score is " + score[i] + " and grade is B");
        else if (score[i] >= max - 30 && score[i] < max - 20)
            System.out.println("Student " + i + " score is " + score[i] + " and grade is C");
        else if (score[i] >= max - 40 && score[i] < max - 30)
            System.out.println("Student " + i + " score is " + score[i] + " and grade is D");
        else
            System.out.println("Student " + i + " score is " + score[i] + " and grade is F");
    }


}
Jun.09,2022

refer to the following code

  https://stackoverflow.com/que...

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36376-2c024.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36376-2c024.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?