Chapter 7
- lang
- Math
- Math.pow(x, 2)
- Numeric
- 22.0
- 9.0
- True
- True
- True
- False
- True
- 2116
- 9.0
- 7.0
- 37.0
- 4.0
- 51
- 4.5
- 2.3
- 61.0
- 92.0
- 20.0
- 43.0
- F = Mat.abs(a+7) + Math.abs(b*2) * a * b
- M = Math.Pow( ( Math.pow(a,3) + Math.pow(b,3) + Math.pow(c,2) ), (1/2))
- f = u * t + 0.5 * a * t * t
- E = Math.pow( (a * x + b * x + c * c), (1/3));
- p = Math.abs(A-B)
- 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 );
}
}