import java.io.*; class PowerIt1 { public static void main(String[] args) throws IOException { int n,m; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter number n : "); n = Integer.parseInt(in.readLine()); System.out.print("Enter number m : "); m = Integer.parseInt(in.readLine()); System.out.print(n+" to the power of "+m+" is: "); System.out.println(power(n,m)); } public static int power(int n, int m) // Calculates n to the power of m iteratively { int acc=1, count=0; while(count!=m) { acc=acc*n; count=count+1; } return acc; } }