Maths class
unknown
java
a month ago
1.1 kB
19
Indexable
public class maths_methods {
public static void main(String[] args){
// Value of pi
// Don't need to create variable -> we have math class
//System.out.println(Math.PI);
// Euler's number
//System.out.println(Math.E);
// power to (x^x)
//double number = Math.pow(3, 3);
// ABS() - absolute value - returns real number if it's negative
//System.out.println(Math.abs(-10));
// .sqrt() - square root
//System.out.println(Math.sqrt(25));
// .round() - rounds to the nearest int (whole number)
//System.out.print(Math.round(5.12));
// .ceil() - always rounds up
//System.out.print(Math.ceil(5.2));
// .floor() - always rounds down
//System.out.print(Math.floor(3.5));
// .max() - returns greater number between 2 or more values
//System.out.print(Math.max(15, 50));
// .min() - returns smaller number between 2 or more values
//System.out.print(Math.min(15, 50));
}
}Editor is loading...
Leave a Comment