Hi,
So basically this is a game that you have to hit targets on a grid. every time there's a "hit" the hitCounter is ++ .
in the end of the game it display a message according to your results. (e.g if you hit 4 out of four - 100% the message is "perfect game", if you hit 3 out of four the message is "very good" .... etc.)
well, that's my plan... but the code seems to take me every time to one place.
Assume that in the end hitCounter is 1, NUMBER_OF_TARGETS is always 2 and FIFTY_PERCENT is always 0.5 it will go here:
else if ((hitCounter/NUMBER_OF_TARGETS) < FIFTY_PERCENT) { System.out.println("\nSorry, you only hit "+hitCounter+" target(s) out of " + NUMBER_OF_TARGETS); }
I tested it many times with different numbers. there were times when I hit nothing and it was ok because if(hitCounter== 0) works.
But even if I have perfect game and more than 50% hits it will take me to the same place.
it's probably something in the division, maybe i'm implementing it wrong.
I hope i describe the problem good enough.
Thanks ahead for your help