-
Lenguaje
Java usando Scanner
-
Descripción
Calcular la potencia de un número.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.Scanner;
public class PotenciaDeUnNumero {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double base, exponente, potencia;
System.out.print("Ingresa el valor de base: ");
base = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de exponente: ");
exponente = in.nextDouble();
in.nextLine();
potencia=Math.pow(base,exponente);
System.out.println("Valor de potencia: " + potencia);
}
}
public class PotenciaDeUnNumero {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double base, exponente, potencia;
System.out.print("Ingresa el valor de base: ");
base = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de exponente: ");
exponente = in.nextDouble();
in.nextLine();
potencia=Math.pow(base,exponente);
System.out.println("Valor de potencia: " + potencia);
}
}