欢迎来到天天文库
浏览记录
ID:8961355
大小:21.81 KB
页数:2页
时间:2018-04-13
《java程序计算π值的近似值循环次数数》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、importjava.util.Scanner;publicclassCaculate{publicstaticvoidmain(Stringargs[]){Scannerinput=newScanner(System.in);doublesum=0;doubleb;intk=-1;doublepi;intcount=0;System.out.print("inputtheterms:");intn=input.nextInt();for(inti=1;i2、(pi<3.14){System.out.printf("%f%d",pi,count);System.out.print("");}if((pi<3.141)&&(pi>3.14)){System.out.printf("%f%d",pi,count);System.out.print("");}if((pi>3.141)&&(pi<3.1415)){System.out.printf("%f%d",pi,count);System.out.print("");}if((pi>3.1415)&&(pi<3.1459)){System.ou3、t.printf("%f%d",pi,count);System.out.print("");}}}}
2、(pi<3.14){System.out.printf("%f%d",pi,count);System.out.print("");}if((pi<3.141)&&(pi>3.14)){System.out.printf("%f%d",pi,count);System.out.print("");}if((pi>3.141)&&(pi<3.1415)){System.out.printf("%f%d",pi,count);System.out.print("");}if((pi>3.1415)&&(pi<3.1459)){System.ou
3、t.printf("%f%d",pi,count);System.out.print("");}}}}
此文档下载收益归作者所有