You have two problems.
First and foremost, you are performing integer division
double test1 = 100 * one / rolls;
100
, one
and rolls
are all int
. This means the result is an integer, regardless of what you've declared the return type to be. This is covered in the SO question Why the result of 1/3=0 in java?:
the result variable as double just causes an implicit conversion to occur after division.
If you want double
s, use doubles:
double one = 432.0;
double rolls = 953.0;
After fixing that, your division of Math.round( test1 * 100.0 ) / 100.0;
will produce a double
, but probably with more than two places of precision. It's unclear at that point if you want further rounding to a specific precision, but if you only wanted to print the two digits after the decimal you could use:
System.out.printf("%.2f", finalValue1);