I am trying to calculate a percentage based on shots/kills.

I have the following but it will either return 100 (shots == kills) or 0 (shots > kills).

public static int shotsFired = 0;
double accuracy = (kills / shotsFired) * 100;

For this example kills = 5 and shots = 6 which should equal 83.3. So why does it return 0?

Note that this isnt the full code and the shotsFired variable is declared outside of the function where accuracy is calculated.

Hi

it returns 0 because you need to convert kills and shotsFired in double.

5/6100=0
but 5.0/6.0
100 = 83.3

if using int’s - cast them as floats…

float perc = ((float)count / (float)countLength * 100); // without float would return zer0