public class Exponent
extends java.lang.Object
Constructor and Description |
---|
Exponent() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
Gets an integer for base and exponent from the console, passes them to
method power() and displays the resulting power of the base to a
showMessageDialog().
|
static int |
power(int base,
int exponent)
A recursive method that calculates and returns an integer (base)
raised to a given power (exponent).
|
public static void main(java.lang.String[] args)
args
- the String[] array command line parameterjava.lang.NumberFormatException
- if user enters non-integer input for 'exponent'public static int power(int base, int exponent) throws java.lang.Exception
base
- the number to be raised to the power of the exponent parameterexponent
- the power to which the base number will be raisedjava.lang.Exception
- thrown if the exponent parameter is a negative number