Respuesta :
Answer:
In Java:
import java.util.Scanner;
import java.lang.Math;
public class MyClass {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
float x, y, z;
System.out.print("Enter three numbers: ");
x = input.nextFloat(); y = input.nextFloat(); z = input.nextFloat();
System.out.print("Square root of x: ");
System.out.printf("%.2f",Math.sqrt(x));
System.out.println();
System.out.print("Absolute of y - z: ");
System.out.printf("%.2f",Math.abs(y - z));
System.out.println();
int fact = 1;
for(int i = 1;i<=(int)Math.ceil(z);i++){
fact*=i;
}
System.out.print("Factorial of z: "+fact);
}
}
Explanation:
This line declares x, y and z as float
float x, y, z;
This line prompts user for three numbers
System.out.print("Enter three numbers: ");
The next line get input for x, y and z
x = input.nextFloat(); y = input.nextFloat(); z = input.nextFloat();
The italicized prints the square root of x rounded to 2 decimal places
System.out.print("Square root of x: ");
System.out.printf("%.2f",Math.sqrt(x));
System.out.println();
The italicized prints the absolute of y - z to 2 decimal places
System.out.print("Absolute of y - z: ");
System.out.printf("%.2f",Math.abs(y - z));
System.out.println();
This initializes fact to 1
int fact = 1;
The following iteration calculates the factorial of ceil z
for(int i = 1;i<=(int)Math.ceil(z);i++){
fact*=i;
}
This prints the calculated factorial
System.out.print("Factorial of z: "+fact);
}
}