Explore Westonci.ca, the top Q&A platform where your questions are answered by professionals and enthusiasts alike. Join our platform to connect with experts ready to provide detailed answers to your questions in various areas. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
Sagot :
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);
}
}
We hope this was helpful. Please come back whenever you need more information or answers to your queries. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.