Question

In Java Given three floating-point numbers x, y, and z, output x to the power of...

In Java

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).

Ex: If the input is:

3.6 4.5 2.0

the output is:

12.96 1.841304610218211E11 4.5 16.2
0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have provide the code with proper comments and proper indentation and also shared the screenshots for proper indentation.

CODE:

//importing the modules
//Here I have used the
//Math module from the util
import java.lang.*;
import java.util.*;

public class Main{
    public static void main(String[] args){
        //declaring the varibles
        double x,y,z;

        //initializing the scanner to take the input
        Scanner s = new Scanner(System.in);

        //taking the inputs
        x = s.nextDouble();
        y = s.nextDouble();
        z = s.nextDouble();
        //calculating the results
        double result1 = Math.pow(x, z);
        //(x^y)^z
        double result2 = Math.pow(x,Math.pow(y, z));

        //sqrt((x*y)^z)
        double result3 = Math.pow(Math.pow(x*y, z),0.5);

        //printing the results
        System.out.println(result1 + " " + result2 + " " + y + " " + result3);
    }

}

//You can compile the code using "javac Main.java" command and run the same using "java Main" command.

Screenshots:

Output:

HAPPY CODING!

Add a comment
Know the answer?
Add Answer to:
In Java Given three floating-point numbers x, y, and z, output x to the power of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT