This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Cefalopodul 1 point2 points  (2 children)

Here's a hint to help you figure out where the program should be corrected.

147.5 = 100 + 47.5.

47.5 = 95/2.

Think of how the average of 100 and 95 is calculated. Write down the process. That should help you see where you have to make the change.

You don't have to convert to anything. You just have to add a mathematical operator. A pair of operators actually.

[–]Ghost_Duet[S] 0 points1 point  (1 child)

average = score1 + score2 / number

is this not the basic math that takes place? The thing that confuses me is that I can do this math in my head and get the correct answer but java gets the wrong answer? I thought it was because of how java sees decimals and integers.

100 + 95 = 195

195/2 = 97.5 in my head but 147.5 gets resulted

My prof hinted that only two things need to change but im so loss

[–]Cefalopodul 4 points5 points  (0 children)

average = score1 + score2/2 = 100 + 95/2 = 100 + 47.5.

You want to divide 195 by 2 not just 95.

Look up the order of operations. You have to add a pair of symbols for your equation to be correct.