Constructor and Description |
---|
StopwatchCPU()
Initializes a new stopwatch.
|
Modifier and Type | Method and Description |
---|---|
double |
elapsedTime()
Returns the elapsed CPU time (in seconds) since the stopwatch was created.
|
static void |
main(String[] args)
Unit tests the
StopwatchCPU data type. |
public double elapsedTime()
public static void main(String[] args)
StopwatchCPU
data type.
Takes a command-line argument n
and computes the
sum of the square roots of the first n
positive integers,
first using Math.sqrt()
, then using Math.pow()
.
It prints to standard output the sum and the amount of time to
compute the sum. Note that the discrete sum can be approximated by
an integral - the sum should be approximately 2/3 * (n^(3/2) - 1).args
- the command-line arguments