int powerOfNumber = (int) Math.pow(number, power);
@Test
public void powerOfTheNumberProgram13() {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter any NUMBER: ");
int number = scanner.nextInt();
System.out.println("Enter the POWER: ");
int power = scanner.nextInt();
scanner.close();
// Logic for finding the POWER of number
int powerOfNumber = (int) Math.pow(number, power);
System.out.println("Power of a " + number + "^" + power + ": " + powerOfNumber);
}
package javaprogramms;
import java.util.Scanner;
public class powermethod {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter Base Number: ");
int base=sc.nextInt();
System.out.println("Enter Power Number: ");
int pw=sc.nextInt();
power(base,pw);
}
public static void power(int base, int pw) {
int res=1;
while(pw>0) {
res=res*base;
pw--;
}
System.out.println("Result: "+res);
}
}