Search code examples
javamethodscall

how can I take one methods result as another methods' parameter


I need to take this "over" statement under the overallmethod as finalmethods' parameter, how can I do this. I want to learn the final letter but to do that I want to access over statement.

public static void overallmethod(int quiz1,int quiz2,int quiz3,int     midterm,int grade){
          double quizzes = ( ((quiz1*10) + (quiz2*10) + (quiz3*10)) *25) /300;
          double finalg = ( grade * 40) / 100;
          double mid = (midterm * 35) / 100;
          double over = quizzes + finalg + mid;
          System.out.println("Your overall score is: " + over);
      }


        public static void finalmethod(double over){


        if(over <= 100 && over >= 90){

            System.out.println("Your final letter is: A");
        }
        else if(over >= 80) {
            System.out.println("Your final letter is: B");
        }
        else if (over >= 70) {
            System.out.println("Your final letter is: C");
        }
        else if (over >= 60) {
            System.out.println("Your final letter is: D");
        }
        else{
            System.out.println("Your final letter is: F");
        }
    }

Solution

  • over is not a statement, it is a local variable now. Just make it class attribute:

    public static double over