Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CalcThePowerOfANum {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the base number: ");
- int base = sc.nextInt();
- System.out.print("Enter the exponent number: ");
- int exponent = sc.nextInt();
- int result = 1;
- for (int i = 1; i <= exponent; i++) {
- result *= base;
- }
- System.out.println(base + " to the power of " + exponent + " is: " + result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement