Phil Maqui wrote:Oh btw the reason that i did multiplication by 10^7 and got the floors then divided it back to 10^7 is because our professor wanted every calculation result at cut at exactly 7 decimal places and uses that value in any subsequent calculation.
In which case I'd put it in a separate method (
round(int)?), because it has nothing to do with calculating a quadratic and just confuses your readers.
Alternatively, you could just trim the excess when you print it out, viz:
System.out.printf("%.7f%n", r1);
Oh, and just to add to what Jesper said:
(-1 * b) ==
-b.
I also tend to add brackets for clarity even if they're not strictly required, eg:
(-b + Math.sqrt(dFinal)) / (2 * a)
rather than
-b + Math.sqrt(dFinal) / (2 * a)
although I think most of yours are OK.
Winston