我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!
天气: 晴朗
心情: 高兴
/*fileName:P5Q15.java
*Name:Wang Chaoran
* Description:
15 (Using the Math.sqrt method)
Write a program that prints the following table using the sqrt method in the Math class.
Number SquareRoot
0 0.0000
2 1.4142
...
18 5.2426
20 5.4721
*/
public class P5Q15{
public static void main(String[] args){
System.out.println("Number SquareRoot");
for(int i=0;i<=20;i+=2){
if(i<10)
System.out.print(" ");
System.out.print(i+" ");
System.out.printf("%-6.4f",squareRoot(i));
System.out.println();
}
}
public static double squareRoot(int input){
return Math.sqrt(input);
}
}
导入论坛查看(36)回复(0)引用(0)好评(0) 差评(0)
加入收藏
编辑
审核
TAG:
computing