//CS5-HMC-Sp.,00-Lab 11 //A. Khakpour, Apr., 00 import java.io.*; class Power { //----------------------------------------------------------------------- // Read in values for x and y from standard input, and computes // x to the power y. //----------------------------------------------------------------------- public static void main (String[] args) throws IOException { InputStreamReader a = new InputStreamReader(System.in); BufferedReader b = new BufferedReader(a); String c; System.out.print ("Enter the value of x: "); c = b.readLine(); int x = Integer.parseInt(c); System.out.print ("Enter the value of y: "); c = b.readLine(); int y = Integer.parseInt(c); System.out.println("x to the power y equals: " + power(x,y)); } //----------------------------------------------------------------------- // Recursively compute x to the y and return the result. //----------------------------------------------------------------------- public static int power (int x, int y) { if (y == 0) return 1; return x * power(x, y-1); } }