Monday, March 30, 2015

JAVA- Math class Method - 1

Math.pow()

 

 

import java.util.Scanner;
public class POwer {
    public static void main(String[] args) {
 
        Scanner v = new Scanner(System.in);
        int a;
        System.out.println("Enter a number :");
        a= v.nextInt();
        System.out.println("Result is "+Math.pow(2, a));
    }
}

 


 


Math.abs();





 
public class AbsMAthClass {
 public static void 
main(String[] args) {
 
System.out.println(Math.abs(-26.3));
 }
}





        Math.ceil()
        Math.floor();
        Math.max();
        Math.min();
        Math.sqrt();





 
public class MathClassMethod {
 public static void main(String[] args) 
{
 
System.out.println(Math.ceil(26.3));
 
System.out.println(Math.floor(26.3));
 
System.out.println(Math.max(8,6));
 
System.out.println(Math.min(8,6));
 
System.out.println(Math.sqrt(25));
 }
}

No comments:

Post a Comment