hi there. Just wanna check if I am coding this wrongly,
int sumOfVotes = 23 int howlong = 94 double SimPercent = ((sumOfVotes / howlong) *100);
Shouldn't the answer, SimPercent, be 24.4?
The problem is you are doing integer division, which will truncate rather than round as you expect. In Java,
5/2 = 2 and
2/5 = 0 . To fix this problem, you need to make one of the operands in the division a floating point type (either float or double). Again, in Java,
(float)5/2 = 2.5 and
2/(double)5 = 0.5 .
THANKSSSSS, you're soooo brilliant!!!!