Stopping and Restarting a Stopwatch
<p>This compares the time it takes to find the Square root using Math.sqrt and Newton's Method. I am supposed to add methods to this that allows the client to stop and restart the stop watch, but I'm not sure how to do this. Searching other questions didn't result in much luck, unfortunately. As this is for a class, I don't want the outright answer given to me, but some advice, or a link to a tutorial on how to accomplish my goal would be nice. Thanks for any help.       </p>

<pre><code>public class Stopwatch 
    {
private final long start;

public Stopwatch()
{ start = System.currentTimeMillis(); }

public double elapsedTime()
{
    long now = System.currentTimeMillis();
    return (now - start) / 1000.0;
}

public static void main(String[] args)
{
    int N = Integer.parseInt(args[0]);

    double totalMath = 0.0;
    Stopwatch swMath = new Stopwatch();
    for (int i = 0; i &lt; N; i++)
        totalMath += Math.sqrt(i);
    double timeMath = swMath.elapsedTime();

    double totalNewton = 0.0;
    Stopwatch swNewton = new Stopwatch();
    for (int i = 0; i &lt; N; i++)
        totalNewton += Newton.sqrt(i);
    double timeNewton = swNewton.elapsedTime();

    System.out.println(totalNewton/totalMath);
    System.out.println(timeNewton/timeMath);
}

}
</code></pre>
