You are using integer arithmetics, which means that your result gets converted to an int
before being saved in the percent
variable.
To avoid this, just cast one of the variables like this:
double percent = (double)dicer / numRol;
As @PaulHicks says, you really should multiply by 100
. You can do it like this, by declaring it as a floating point literal (100.0
), to avoid casting altogether:
double percent = 100.0 * dicer / numRol;