|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPowerDemo
public class PowerDemo
The PowerDemo Java application illustrates the use of
the power and pow methods, which use recursion to
calculate the value of a number raised to an integer power.
| Constructor Summary | |
|---|---|
PowerDemo()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
The main method activates power and
pow with parameters that are provided by the user. |
static double |
pow(double x,
int n)
Alternate implementation of the power method. |
static double |
power(double x,
int n)
Computes the value of x raised to the n power. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PowerDemo()
| Method Detail |
|---|
public static void main(java.lang.String[] args)
main method activates power and
pow with parameters that are provided by the user.
The String arguments (args) are not used
in this implementation.
public static double power(double x,
int n)
x raised to the n power.
x - any double numbern - the int power to raise x to
x is zero, then n must be positive.
x raised to the n power
java.lang.IllegalArgumentException - Indicates that x is zero and n is not positive.
public static double pow(double x,
int n)
power method.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||