find n power of any number using java

Example to find the N power of any number in java
Below is the code

import java.io.*;

public class NPowerOfNumber {

public static void main(String[] args) {
try {
DataInputStream in = new DataInputStream(System.in);

System.out.print(“Enter the Number :- “);
String strNumber = in.readLine();
int Number = Integer.parseInt(strNumber);

System.out.print(“Enter the Power :- “);
strNumber = in.readLine();
int PowerValue = Integer.parseInt(strNumber);

Double Answer = Math.pow(Number, PowerValue);

System.out.println(“The ” + PowerValue + ” Power of ” + Number
+ ” = ” + Answer);
} catch (Exception e) {
System.out.println(“Exception found = ” + e);
}
}
}


Output of the above program

Enter the Number :- 4
Enter the Power :- 4
The 4 Power of 5 = 256.0