0
if ((double) (points / tries) > hiScore) {
                        hiScore = (double) points / tries;
                        hiPoints = points;
                        hiTries = tries;

I cannot understand why hiScore, or even points / tries, always remain = 0 (points and tries are both ints, same as hiPoints and hiTries)

mr.uaila
  • 3
  • 5

1 Answers1

0

Try this

if ( ((double) points / tries) > hiScore) {
                    hiScore = (double) points / tries;
                    hiPoints = points;
                    hiTries = tries;

Or even this (shouldn't be necessary, because of the priority cast operation has over division):

if ( (((double) points) / tries) > hiScore) {
                    hiScore = ((double) points) / tries;
                    hiPoints = points;
                    hiTries = tries;

You need to cast your integer variable before division operation.

Luca C.
  • 56
  • 3
  • Happy to help, and welcome to Stack Overflow. If this answer solved your issue, please mark it as accepted. – Luca C. Aug 11 '17 at 11:01