Math Methods
import java.util.Scanner; class P07MathsMethods { public static void main() { int x, y; System.out.println("Enter two integers to use math method"); Scanner in = new Scanner(System.in); x = in.nextInt(); y = in.nextInt(); System.out.println("\n Square root of the fisrt integer = " + Math.sqrt(x)); System.out.println("\n Power function x^y = " + Math.pow(x,y)); System.out.println("\n Sine of the fisrt integer = " + Math.sin(x)); System.out.println("\n Absolute value of the first integer = " + Math.abs(x)); System.out.println("\n Cube root of the first integer = " + Math.cbrt(x)); System.out.println("\n Maximum of two integer = " + Math.max(x,y)); System.out.println("\n Minimum of two integer = " + Math.min(x,y)); System.out.println("\n Random value = " + Math.random()); System.out.println("\n Random Integer of 4 digit= " + (int)(Math.random()*10000)); } }
Comments
Post a Comment