Find ceiling
value of a number using Math
public class
FindCeilingExample
{
public static void
main(String[] args)
{
System.out.println(Math.ceil(10));
System.out.println(Math.ceil(10.1)); System.out.println(Math.ceil(5.5));
System.out.println(Math.ceil(-20));
System.out.println(Math.ceil(-42.4));
System.out.println(Math.ceil(0));
}
}
Find
exponential value of a number using Math
public class
FindExponentialNumberExample
{
public static void
main(String[] args)
{
System.out.println("Exponential
of 2 is : " + Math.exp(2));
}
}
Find floor
value of a number using Math
public class
FindFloorValueExample
{
public static void
main(String[] args)
{
System.out.println(Math.floor(70));System.out.println(Math.floor(30.1));System.out.println(Math.floor(15.5));
System.out.println(Math.floor(-40)); System.out.println(Math.floor(-42.4));
System.out.println(Math.floor(0));
}
}
Find maximum of
two numbers using Math
public class
FindMaxOfTwoNumbersExample
{
public static void main(String[] args)
{
System.out.println(Math.max(20,40));
System.out.println(Math.max(324.34f,432.324f));
System.out.println(Math.max(65.34,123.45));
System.out.println(Math.max(435l,523l));
}
}
Find minimum of
two numbers using Math
public class
FindMinimumOfTwoNumbersExample
{
public static void
main(String[] args)
{
System.out.println(Math.min(34,45));
System.out.println(Math.min(43.34f,
23.34f));System.out.println(Math.min(4324.334, 3987.342));
System.out.println(Math.min(48092840,4230843));
}
}
Find natural
logarithm value of a number using Math
public class
FindNaturalLogarithmOfNumberExample
{
public static void main(String[] args)
{
System.out.println("Natural
logarithm value of 2 is : " + Math.log(2));
}
}
Find power
using Math
public class
FindPowerExample
{
public static void
main(String[] args)
{
System.out.println(Math.pow(2,2));
System.out.println(Math.pow(-3,2));
}
}
No comments:
Post a Comment