public
class
MathLibraryExample {
public
static
void
main(String[] args)
{
int
i =
7
;
int
j = -
9
;
double
x =
72.3
;
double
y =
0.34
;
System.out.println(
"i is "
+ i);
System.out.println(
"j is "
+ j);
System.out.println(
"|"
+ i +
"| is "
+ Math.abs(i));
System.out.println(
"|"
+ y +
"| is "
+ Math.abs(y));
System.out.println(x +
" is approximately "
+ Math.round(x));
System.out.println(y +
" is approximately "
+ Math.round(y));
System.out.println(
"The ceiling of "
+ x +
" is "
+ Math.ceil(x));
System.out.println(
"The ceiling of "
+ y +
" is "
+ Math.ceil(y));
System.out.println(
"The floor of "
+ x +
" is "
+ Math.floor(x));
System.out.println(
"The floor of "
+ y +
" is "
+ Math.floor(y));
System.out.println(
"min("
+ i +
","
+ j +
") is "
+ Math.min(i, j));
System.out.println(
"min("
+ x +
","
+ y +
") is "
+ Math.min(x, y));
System.out.println(
"max("
+ i +
","
+ j +
") is "
+ Math.max(i, j));
System.out.println(
"max("
+ x +
","
+ y +
") is "
+ Math.max(x, y));
System.out.println(
"Pi is "
+ Math.PI);
System.out.println(
"e is "
+ Math.E);
double
angle =
45.0
*
2.0
* Math.PI /
360.0
;
System.out.println(
"cos("
+ angle +
") is "
+ Math.cos(angle));
System.out.println(
"sin("
+ angle +
") is "
+ Math.sin(angle));
double
value =
0.707
;
System.out.println(
"acos("
+ value +
") is "
+ Math.acos(value));
System.out.println(
"asin("
+ value +
") is "
+ Math.asin(value));
System.out.println(
"atan("
+ value +
") is "
+ Math.atan(value));
System.out.println(
"exp(1.0) is "
+ Math.exp(
1.0
));
System.out.println(
"exp(10.0) is "
+ Math.exp(
10.0
));
System.out.println(
"exp(0.0) is "
+ Math.exp(
0.0
));
System.out.println(
"log(1.0) is "
+ Math.log(
1.0
));
System.out.println(
"log(10.0) is "
+ Math.log(
10.0
));
System.out.println(
"log(Math.E) is "
+ Math.log(Math.E));
System.out.println(
"pow(2.0, 2.0) is "
+ Math.pow(
2.0
,
2.0
));
System.out.println(
"pow(10.0, 3.5) is "
+ Math.pow(
10.0
,
3.5
));
System.out.println(
"pow(8, -1) is "
+ Math.pow(
8
, -
1
));
for
(i =
0
; i <
10
; i++) {
System.out.println(
"The square root of "
+ i
+
" is "
+ Math.sqrt(i));
}
System.out.println(
"Here's one random number: "
+ Math.random());
}
}