JAVA CODE
//program of Ex4.36 import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Ex4_36 extends Applet implements ActionListener { Label prompt1, prompt2; TextField num1, num2; int base, exponent; public void init() { prompt1 = new Label(" Enter the base : " ); add(prompt1); num1 = new TextField(3); num1.addActionListener(this); add(num1); prompt2 = new Label(" Enter the exponent : " ); add(prompt2); num2 = new TextField(3); num2.addActionListener(this); add(num2); } public void paint(Graphics g) { long answer = power (base, exponent); g.drawString("The answer is "+base+" ^ "+exponent+" = "+answer, 80, 100 ); } private long power (int base, int exponent) { long product = base; for (int i = 1; i < exponent; i++) product = product * base; return product; } public void actionPerformed(ActionEvent e) { base = Integer.parseInt( num1.getText() ); exponent = Integer.parseInt( num2.getText() ); repaint(); } }