-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathMethods.java
More file actions
31 lines (25 loc) · 1.36 KB
/
Copy pathMathMethods.java
File metadata and controls
31 lines (25 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class MathMethods {
public static void main(String[] args) {
System.out.println(Math.pow(2, 5)); // 2 raised to the power of 5
System.out.println(Math.abs(-5)); // Returns the absolute value
System.out.println(Math.sqrt(9)); // Returns the square root
System.out.println(Math.cbrt(27)); // Returns the cube root
System.out.println(Math.round(3.1548561)); // Rounds to the nearest whole number
System.out.println(Math.round(3.7845)); // Rounds to the nearest whole number
System.out.println(Math.ceil(9.1451)); // Rounds up to the next whole number
System.out.println(Math.floor(5.98522)); // Rounds down to the previous whole number
System.out.println(Math.max(10, 20)); // Returns the larger of two numbers
System.out.println(Math.min(485, 844)); // Returns the smaller of two numbers
System.out.println(Math.PI); //Pi value
System.out.println(Math.E); //Euler's value
System.out.println(Math.random()); //random btw 0.0 to 1.0
// Trignometric functions
System.out.println(Math.sin(90));
System.out.println(Math.cos(90));
System.out.println(Math.tan(90));
// Log functions
System.out.println(Math.log(10));
System.out.println(Math.log10(15));
System.out.println(Math.exp(5)); // e raised to power of 9
}
}