public class MathExample { public static void main(String[] args) { // TODO Auto-generated method stub System.out.printf("PI to 3 decimal places = %.3f\n", Math.PI); System.out.printf("E to 3 decimal places = %.3f\n", Math.E); int x = 10, y = -5, z = -20; int a1; a1 = Math.abs(x); System.out.println("Absolute value of " + x + " is " + a1); System.out.println("Absolute value of " + y + " is " + Math.abs(y) ); System.out.println("Absolute value of " + z + " is " + Math.abs(z) ); double ans = Math.pow(y,3); int answer = (int)ans; System.out.println(y + " raised to the power of 3 = " + answer); System.out.println(x + " raised to the power of 4 = " + (int)Math.pow(x, 4) ); double a = 3.54; System.out.println("Round of " + a + " is " + Math.round(a)); System.out.println("Ceil of " + a + " is " + Math.ceil(a) ); System.out.println("Floor of" + a + " is " + Math.floor(a) ); double randNum; //[0.0~1.0) randNum = Math.random(); System.out.println("Random number is: " + randNum); for(int i=0; i <10; i++) { //[1~6] int dieRoll = (int)(Math.random() * 6) + 1; System.out.println("Rolling a die: " + dieRoll); } } }