219k views
2 votes
in a java program solve LAB: Using math methods Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to the power of z), the absolute value of y, and the square root of (xy to the power of z).

User Lenkovi
by
7.1k points

1 Answer

6 votes

Answer:

import java.lang.Math;

public class MathLab {

public static void main(String[] args) {

double x = 2.0;

double y = 3.0;

double z = 4.0;

double power1 = Math.pow(x, z);

System.out.println("x to the power of z: " + power1);

double power2 = Math.pow(x, Math.pow(y, z));

System.out.println("x to the power of (y to the power of z): " + power2);

double absY = Math.abs(y);

System.out.println("Absolute value of y: " + absY);

double power3 = Math.pow(x * y, z);

double sqrt = Math.sqrt(power3);

System.out.println("Square root of (xy to the power of z): " + sqrt);

}

}