111k views
1 vote
1. Here is a program segment to find the quantity base . Both base and exp are entered at the keyboard. System.out.println("Enter base and exponent: "); double base = IO.readDouble();// read user input double exp = IO.readDouble(); // read user input /* code to find power, which equals baseexp */ System.out.print(base + " raised to the power " + exp); System.out.println(" equals " + power); Which code is a correct replacement for /* code to find power, which equals baseexp */ ?

1 Answer

6 votes

Answer:

The correct code to this question can be de4fined as follows:

double power;

power = Math.pow(base, exp);

Step-by-step explanation:

In the given question the choices were missing, that's why we defined the correct code only.

  • In the given code a two double variable "base and exp" is declared, that input the value from the user-side, and store its value into there respective variables.
  • In the next step, "power", that is a double variable is declared, which uses the "Math.pow" function that calculates given values power and prints its value.

please find the attachment of the full code.

1. Here is a program segment to find the quantity base . Both base and exp are entered-example-1
User Spike
by
5.5k points