import java.util.Scanner; public class PowerRecursion { public PowerRecursion() { System.out.println("Please type in two numbers to get exponent, type \"exit\" when you are done:"); Scanner sc = new Scanner(System.in); while(sc.hasNext()){ String str1 = sc.next(); if(str1.equals("exit")) break; String str2 = sc.next(); System.out.println("Pow("+str1+", "+str2+")=" + Power(Integer.parseInt(str1), Integer.parseInt(str2))); } } public int Power(int m, int n){ if(n==1) return m; else return m*Power(m, n-1); } public static void main(String args[]){ PowerRecursion s = new PowerRecursion(); } }