Calling a method from another method

joel :

I know the problem exists on the forum, but I am really stuck. I would like to call my grade() method into my display() method to appear the grade. I don't know how to do...

Here is my grade() method

    public static void grade(int note){
            String grade = "";
            if (note <= 70){
                grade = "Satisfaction";
            }
            else{
                grade = "Great Satisfaction";
            }

    }

In my display() method, I want to retrieve the grade for the student.

public static void display(String[] tabStudent, int[] tabNote, char code){

        for(int i=0; i<tabStudent.length;i++){
            if (code == 'e'){
                if (tabNote[ i ] <  50){
                    System.out.println(tabStudent[i] +  " " + tabNote[i] );
                }
            }
            else if(code == 's'){
                if (tabNote[ i ] > 50){
                    System.out.println(tabStudent[i] +  " " + tabNote[i] + grade() );
                }
            }
        }

    }

My problem is this line below:

System.out.println(tabStudent[i] +  " " + tabNote[i] + grade() );

Here is an image

Thank you for your help.

sleepToken :

Well, it needs to actually return something:

public static String grade(int note){
  String grade = "";

  if (note <= 70) {
    grade = "Satisfaction";
  } else {
    grade = "Great Satisfaction";
  }

  return grade;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=31381&siteId=1