利用下面的关键代码编写一个完整的程序KY6_4.java,理解Math类的使用 System.out.println (Math.abs (-5.8)); System.out.println (Math.ceil (3.2)); System.out.println (Math.floor (3.8); System.out.println (Math.round (3.8)); System.out.println (Math.round (3.2)); System.out.println (Math.min (3, 2)); System.out.println (Math.max (Math.PI, 4)); System.out.println (Math.log (7.0)); System.out.println (Math.pow (7,2)); System.out.println (Math.exp (0.4)); System.out.println ("e is:"+ Math.e); System.out.println ("π is:"+Math.PI); System.out.println(Math.random());
时间: 2024-02-25 09:53:56 浏览: 88
以下是完整的程序KY6_4.java,可以运行并输出结果:
```
public class KY6_4 {
public static void main(String[] args) {
System.out.println(Math.abs(-5.8));
System.out.println(Math.ceil(3.2));
System.out.println(Math.floor(3.8));
System.out.println(Math.round(3.8));
System.out.println(Math.round(3.2));
System.out.println(Math.min(3, 2));
System.out.println(Math.max(Math.PI, 4));
System.out.println(Math.log(7.0));
System.out.println(Math.pow(7, 2));
System.out.println(Math.exp(0.4));
System.out.println("e is:" + Math.E);
System.out.println("π is:" + Math.PI);
System.out.println(Math.random());
}
}
```
输出结果:
```
5.8
4.0
3.0
4
3
2
4.0
1.9459101490553132
49.0
1.4918246976412703
e is:2.718281828459045
π is:3.141592653589793
0.3632260047015039
```
阅读全文