|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.simulations.Averager
public class Averager
An Averager computes an average of a group of numbers.
| Constructor Summary | |
|---|---|
Averager()
Initialize an Averager. |
|
| Method Summary | |
|---|---|
void |
addNumber(double value)
Give another number to this Averager. |
double |
average()
Provide an average of all numbers given to this Averager. |
int |
howManyNumbers()
Provide a count of how many numbers have been given to this Averager. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Averager()
Averager.
param - none
Averager has been initialized and is ready to accept numbers.
| Method Detail |
|---|
public void addNumber(double value)
Averager.
value - the next number to give to this Averager
howManyNumbers() < Integer.MAX_VALUE.
Averager has accepted value as the next number.
java.lang.IllegalStateException - Indicates that howManyNumbers() is
Integer.MAX_VALUE.public double average()
Averager.
- - none
Averager
the next number to give to this Averager
howManyNumbers() is zero, then the answer is
Double.NaN ("not a number"). The answer may also be
Double.POSITIVE_INFINITY or
Double.NEGATIVE_INFINITY if there has been an arithmetic
overflow during the summing of all the numbers.public int howManyNumbers()
Averager.
- - none
Averager
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||