(BlueJ) Java Program to Demonstrate Math Class
Code:
Code:
public class MathDemo
{
public static void main()
{ int angle = 45, x=10;
System.out.println("**** Program to display methods of Math Class **** ");
System.out.println("The sin of given angle ==> "+Math.sin(angle));
System.out.println("Demo for Power ==> "+Math.pow(x,2));
System.out.println("Demo for PI ==> "+Math.PI);
System.out.println("Demo for cos "+Math.cos(angle));
System.out.println("Demo for tan ==> "+Math.tan(angle));
System.out.println("Demo for asin ==> "+Math.asin(angle));
System.out.println("Demo for acos ==> "+Math.acos(angle));
System.out.println("Demo for atan ==> "+Math.atan(angle));
System.out.println("Demo for atan2 ==> "+Math.atan2(5,2));
System.out.println("Demo for exponent ==> "+Math.exp(x));
System.out.println("Demo for log ==> "+Math.log(x));
System.out.println("Demo for square root ==> "+Math.sqrt(36));
System.out.println("Demo for ceil of 12.5 ==> "+Math.ceil(12.5));
System.out.println("Demo for floor of 12.5 ==> "+Math.floor(12.5));
System.out.println("Demo for rint of 17.99 ==> "+Math.rint(17.99));
System.out.println("Demo for absolute of -17.99 ==> "+Math.abs(17.99));
System.out.println("Demo for maximum of 45 and 42 ==> "+Math.max(45,42));
System.out.println("Demo for minimum of 45 and 42 ==> "+Math.min(45,42));
System.out.println("Dome for random number ==> "+Math.random());
}
}
{
public static void main()
{ int angle = 45, x=10;
System.out.println("**** Program to display methods of Math Class **** ");
System.out.println("The sin of given angle ==> "+Math.sin(angle));
System.out.println("Demo for Power ==> "+Math.pow(x,2));
System.out.println("Demo for PI ==> "+Math.PI);
System.out.println("Demo for cos "+Math.cos(angle));
System.out.println("Demo for tan ==> "+Math.tan(angle));
System.out.println("Demo for asin ==> "+Math.asin(angle));
System.out.println("Demo for acos ==> "+Math.acos(angle));
System.out.println("Demo for atan ==> "+Math.atan(angle));
System.out.println("Demo for atan2 ==> "+Math.atan2(5,2));
System.out.println("Demo for exponent ==> "+Math.exp(x));
System.out.println("Demo for log ==> "+Math.log(x));
System.out.println("Demo for square root ==> "+Math.sqrt(36));
System.out.println("Demo for ceil of 12.5 ==> "+Math.ceil(12.5));
System.out.println("Demo for floor of 12.5 ==> "+Math.floor(12.5));
System.out.println("Demo for rint of 17.99 ==> "+Math.rint(17.99));
System.out.println("Demo for absolute of -17.99 ==> "+Math.abs(17.99));
System.out.println("Demo for maximum of 45 and 42 ==> "+Math.max(45,42));
System.out.println("Demo for minimum of 45 and 42 ==> "+Math.min(45,42));
System.out.println("Dome for random number ==> "+Math.random());
}
}
Comment below for your Query and Feedback... :)
0 comments:
Confused? Feel free to ask
Post a Comment