import javax.swing.*; class PowerGraphics1 { public static void main(String[] args) { int n,m; String input = JOptionPane.showInputDialog("Enter number n : "); n = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter number m : "); m = Integer.parseInt(input); System.out.print(n+" to the power of "+m+" is: "); System.out.println(power(n,m)); System.exit(0); } 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; } }