public static boolean gradeCalculator() {
double mark,student;
String grade = "";
double total = 0;
System.out.println("Enter number of students :");
student = scanner.nextDouble();
for(int i=0; i<student; i++){
System.out.println("Enter mark for student "+ (i+1) +" : ");
mark = scanner.nextDouble();
total = total + mark;
double average = total/student;
{
if(mark >=0 && mark <=39){
grade = "F" ;
}
else if(mark >=40 && mark <=49){
grade = "P";
}
else if(mark >=50 && mark <=59){
grade = "D";
}
else if(mark >=60 && mark <=69){
grade = "C";
}
else if(mark >=70 && mark <=79){
grade = "B";
}
else if(mark >=80 && mark <100){
grade = "A";
}
System.out.println( "Grade : " +grade);
}
}
System.out.println( "Average Mark : " +total/student);
System.out.println( "Average Grade : " );
System.exit(0);
return false;
}
I wanted to calculate the grade for students, and the average at the end of the script. But i'm wondering how do i make the average mark refer to the grade which i created previously in the if-else statement.
Aucun commentaire:
Enregistrer un commentaire