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