Chapter 7

  1. lang
  2. Math
  3. Math.pow(x, 2)
  4. Numeric
  5. 22.0
  6. 9.0

  1. True
  2. True
  3. True
  4. False
  5. True

  1. 2116
  2. 9.0
  3. 7.0
  4. 37.0
  5. 4.0
  6. 51
  7. 4.5
  8. 2.3
  9. 61.0
  10. 92.0
  11. 20.0
  12. 43.0

  1. F = Mat.abs(a+7) + Math.abs(b*2) * a * b
  2. M = Math.Pow( ( Math.pow(a,3) + Math.pow(b,3) + Math.pow(c,2) ), (1/2))
  3. f = u * t + 0.5 * a * t * t
  4. E = Math.pow( (a * x + b * x + c * c), (1/3));
  5. p = Math.abs(A-B)
  6. Math.pow(x,2) + Math.pow(y, 2) + 2 * x * y

Ans:

public class q5

{    

    public static void main()

    {

                 int num = -254;

                    int absNum = Math.abs(num);

                double num2  = 125.0;

                System.out.println( math.cbrt(num2) );

                    System.out.println(absNum);

    }

}

Ans:

public class q6

{

   

    public static void main(String args[])

    {

        System.out.println( Math.sqrt(96.0) );

       

        System.out.println( Math.pow(5,3) );

       

        System.out.println( Math.ceil(32.65) );

       

        System.out.println( Math.floor(14.44) );

    }

}

Output:

9.797958971132712

125.0

33.0

14.0

import java.util.*;

public class q7

{

   

    public static void main()

    {

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter value of m and n:");

        int m = sc.nextInt();

        int n = sc.nextInt();

       

        System.out.println( Math.pow(m,n) );

        System.out.println( Math.sqrt(m) );

        System.out.println( Math.cbrt(n) );

        System.out.println( Math.max(m,n) );

    }

}

Ans:

import java.util.*;

public class q8

{

   

    public static void main()

    {

        Scanner sc = new Scanner(System.in);

       

        System.out.println("Enter value of m and n:");

        double m = sc.nextDouble();

        double n = sc.nextDouble();

        double max = Math.max(m,n);

        double min = Math.min(m, n);

       

        System.out.println("Rounded value of " + (m + n) + ": " +

Math.round(m + n) );

       

        System.out.println("Smallest: " + min );

       

        System.out.println("Difference between largest and smallest: "

+ (max - min));

    }

}

Ans:

import java.util.*;

public class q9

{

   

    public static void main()

    {

        Scanner sc = new Scanner(System.in);

       

        System.out.println("Enter value of a and b:");

        double a = sc.nextDouble();

        double b = sc.nextDouble();

       

        double z = Math.sqrt( ( Math.pow(a,2) + Math.pow(b,2) ) );

       

        System.out.println(z );

       

    }

}

Ans:

import java.util.*;

public class q10

{    

    public static void main()

    {

        Scanner sc = new Scanner(System.in);

       

        System.out.println("Enter value of a, b, c:");

        double a = sc.nextDouble();

        double b = sc.nextDouble();

        double c = sc.nextDouble();

       

        double s = (a+b+c)/2;

        double c1 =  s*(s-a)*(s-b)*(s-c);

       

        double area = Math.sqrt(c1);

       

        System.out.println( "Area is: " + area );

       

    }

}