编写程序,显示和的结果。在程序中用1.0代替1。 1.7 (Approximate π) can be computed using the following formula:
Write a program that displays the result ofanduse 1.0 instead of 1 in your program.
参考代码:
package chapter01;publicclassCode_07{publicstaticvoidmain(String[] args){
System.out.println("The Approximate Number Of PI : "+4*(1.0-1.0/3+1.0/5-1.0/7+1.0/9-1.0/11));
System.out.println("The Approximate Number Of PI : "+4*(1.0-1.0/3+1.0/5-1.0/7+1.0/9-1.0/11+1.0/13));}}
结果显示:
The Approximate Number Of PI :2.9760461760461765
The Approximate Number Of PI :3.2837384837384844
Process finished with exit code 0
第一章第七题(求π的近似值)(Approximate π)1.7(求π的近似值)可以使用以下公式计算π:编写程序,显示和的结果。在程序中用1.0代替1。1.7 (Approximate π) can be computed using the following formula:Write a program that displays the result ofanduse 1.0 instead of 1 in your program.参考代码:package chapter01