Skip to content

Commit 75c6076

Browse files
authored
Create Java code explaining atan(), ceil(), copySign() method in lang.Math class
1 parent 9fd3485 commit 75c6076

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Java program explaining lang.Math class methods
2+
// atan(), ceil(), copySign()
3+
4+
5+
6+
import java.math.*;
7+
8+
public class NewClass
9+
{
10+
11+
public static void main(String[] args)
12+
13+
{
14+
15+
// Use of atan() method
16+
17+
double Atani = Math.atan(0);
18+
19+
System.out.println("atan value of Atani : "+Atani);
20+
21+
double x = Math.PI/2;
22+
23+
24+
25+
// Use of toRadian() method
26+
27+
x = Math.toRadians(x);
28+
29+
double Atanj = Math.atan(x);
30+
31+
System.out.println("atan value of Atanj : "+Atanj);
32+
33+
System.out.println("");
34+
35+
36+
37+
38+
39+
// Use of ceil() method
40+
41+
double val = 15.34 ,ceilval;
42+
43+
ceilval = Math.ceil(val);
44+
45+
System.out.println("ceil value of val : "+ceilval);
46+
47+
System.out.println("");
48+
49+
50+
51+
double dblMag = val;
52+
53+
double dblSign1 = 3;
54+
55+
double dblSign2 = -3;
56+
57+
58+
59+
60+
61+
// Use of copySign() method
62+
63+
double result1 = Math.copySign(dblMag,dblSign1);
64+
65+
System.out.println("copySign1 : "+result1);
66+
67+
68+
69+
double result2 = Math.copySign(dblMag,dblSign2);
70+
71+
System.out.println("copySign2 : "+result2);
72+
73+
74+
75+
}
76+
}

0 commit comments

Comments
 (0)