< Math Class >

EXPLAIN Math ;

>Java Math class provides several methods to work on math calculations.

> like min(), max(), avg(), sin(), cos(), tan(), round(), ceil(), floor(), abs() etc.

ADD EXTRACT ;

> If the size is int or long and the results overflow the range of value.

> the methods addExact(), subtractExact(), multiplyExact(), and toIntExact() throw an ArithmeticException.

PROGRAM ;

public class Math
{


public static void main(String[] args)
{


double x = 1;
double y = 2;


System.out.println(“Maximum number of x and y is: ” +Math.max(x, y));


System.out.println(“Square root of y is: ” + Math.sqrt(y));

System.out.println(“square root of x is:” + math.sqrt(y));


System.out.println(“Power of x and y is: ” + Math.pow(x, y));


System.out.println(“Logarithm of x is: ” + Math.log(x));


System.out.println(“Logarithm of y is: ” + Math.log(y));


System.out.println(“log10 of x is: ” + Math.log10(x));


System.out.println(“log10 of y is: ” + Math.log10(y));


System.out.println(“log1p of x is: ” +Math.log1p(x));


System.out.println(“exp of a is: ” +Math.exp(x));


System.out.println(“expm1 of a is: ” +Math.expm1(x));


}


}

TRIGONO-METRIC MATH ;

public class sin
{


public static void main(String[] args)
{


double a = 30;


double b = Math.toRadians(a);


System.out.println(“Sine value of a is: ” +Math.sin(a));


System.out.println(“Cosine value of a is: ” +Math.cos(a));




System.out.println(“Tangent value of a is: ” +Math.tan(a));


System.out.println(“Sine value of a is: ” +Math.asin(a));


System.out.println(“Cosine value of a is: ” +Math.acos(a));




System.out.println(“Tangent value of a is: ” +Math.atan(a));




System.out.println(“Sine value of a is: ” +Math.sinh(a));




System.out.println(“Cosine value of a is: ” +Math.cosh(a));




System.out.println(“Tangent value of a is: ” +Math.tanh(a));

}


}

Leave a Comment