mardi 2 novembre 2021

Java - Else if is continuing to ELSE Statement [closed]

I'm getting confused on why my block of codes is getting "Grade point equivalence is 5.00"

    //Average and Total
    total = comProg + introComp + Cisco + PE;
    average = total/4;

    //Total and Average Printing
    System.out.println("Total grades for all subjects: " + total);
    System.out.println("My Average is: " + average);

    //Table Of Grades
    String Ex = ("Excellent");
    String Vg = ("Very Good");
    String Gd = ("Good");
    String Fa = ("Fair");
    String Pa = ("Pass");
    String Fe = ("Failure");

    //Grading
    if (average == 100.0) {
        System.out.println("Grade point equivalence is 1.00");
        System.out.println(Ex);
    } else if (average <= 96 && average >= 94.99){
        System.out.println("Grade point equivalence is 1.25");
        System.out.println(Vg);
    } else if (average <= 93 && average >= 92.99){
        System.out.println("Grade point equivalence is 1.50");
        System.out.println(Vg);
    } else if (average <= 91 && average >= 89.99){
        System.out.println("Grade point equivalence is 1.75");
        System.out.println(Gd);
    } else if (average <= 88 && average >= 87.99){
        System.out.println("Grade point equivalence is 2.00");
        System.out.println(Fa);
    } else if (average <= 86 && average >= 84.99){
        System.out.println("Grade point equivalence is 2.25");
        System.out.println(Fa);
    } else if (average <= 83 && average >= 82.99){
        System.out.println("Grade point equivalence is 2.50");
        System.out.println(Fa);
    } else if (average <= 81 && average >= 79.99){
        System.out.println("Grade point equivalence is 2.75");
        System.out.println(Fa);
    } else if (average <= 78 && average >= 75.99){
        System.out.println("Grade point equivalence is 3.00");
        System.out.println(Pa);
    } else {
        System.out.println("Grade point equivalence is 5.00");
        System.out.println(Fe);
    }
    
}

}

Error here

When I input some grades that are resulting to below 1.25 average its working. But whenever I put something like the picture below. Its getting a Failure results So I just want to know what causing this. Thank you sir/mams.

Aucun commentaire:

Enregistrer un commentaire