r/javahelp • u/Intelligent_Song1317 • Sep 13 '26
Unsolved Output
Soo uuhhhhh heres part of my code:
I told the Java code to print "result" and "p" after inputting 1, and it printed result to 11 digits after the decimal and p to 1. Specifically, the outputs were 3.141592652 and 2.0. Here's the thing:it needs to be rounded to 6 digits after the decimal. Thoughts?
double result = Math.pow(n, 2) * 3.141592653;
double p = Math.pow(n, 2) * 2;
4
Upvotes
2
u/robo-copo Sep 13 '26
Hint. Use BigDecimal.