Methods in java (grade calculator)

后端 未结 6 1801
醉酒成梦
醉酒成梦 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 07:11

    A couple of things spring to mind:

    1. You execute scoreCalc() twice. Probably you want to execute it once and save the result in a double variable like: double score = scoreCalc().

    2. Speaking of scoreCalc(): Your definition takes 4 parameters that your don't have as input for that method. You should remove those from your method definition, and instead add score1, maxMark, weighting and finalScorevariable declarations in the method-body.

    3. In your main function, you declare and instantiate a Scanner object you don't use.

    4. Be careful with arithmetic that mixes int and double.

提交回复
热议问题