I'm making an app for a chemical formula, and I have made it so that it returns double coefficients.
For example, C6H12O6 + O2 = CO2 + H2O returns .166666667, 1.0, 1.0, and 1.0. I want to write code so that it is 1, 6, 6, and 6 (integers). Also, for another equation, like Ca(OH)2 + H3PO4 = Ca3(PO4)2 + H2O, the return is .5, .333333333, .166666667, and 1.0. It should be 3, 2, 1, and 6. Is there a way I can convert these to integer coefficients in Java?