Dividing two integers in Java gives me 0 or 100?

What you could do is force it to divide a and b as doubles thus:

int x = (int) (((double) a / (double) b) * 100);

Leave a Comment