Methods in java (grade calculator)

后端 未结 6 1782
醉酒成梦
醉酒成梦 2021-01-29 06:49

We\'ve been learning about methods in java (using netbeans) in class and I\'m still a bit confused about using methods. One homework question basically asks to design a grade ca

6条回答
  •  北海茫月
    2021-01-29 06:50

    As you can see scoreCalc method needs a set of parameters, but you call it without parameters.

    The second: there is no need in Scanner in = new Scanner(System.in); into your main(String[] args) method. You are calling it into scoreCalc method.

    Third: you are calling scoreCalc twice. The first call is before System.out.println, the second is into System.out.println. And your application will ask user twice to enter values.

    store result value in a variable and show it later:

    double result = scoreCalc(.... required params .....);
    System.out.println("Your score is: " + result);
    

提交回复
热议问题