There’s a couple factors missing from your question that makes me unable to completely answer them, but:
Is the courseGrade method in a separate class or in the same class as your public static void main
method?
Yes: Create a new instance of the separate class by doing: public SeparateClass instance = new SeparateClass();
inside of public static void main
After that, call this from your main
method: double grade = instance.courseGrade(homeworkWeightedScore, examTwoWeightedScore, examTwoWeightedScore);
No: Make the courseGrade method static, you can’t call a non-static method from a static method (replace public double courseGrade
with public static double courseGrade
). After that, inside of your main
method, do this: double d = courseGrade(homeworkWeightedScore, examTwoWeightedScore, examTwoWeightedScore);
I hope this helps.
solved call method with parameters java [closed]