Problem

The Java API Calendar class contains a method called getTimeInMillisec which enables you t...

The Java API Calendar class contains a method called getTimeInMillisec which enables you to retrieve the absolute time (in milliseconds) at which any Calendar object was created. As indicated in Section 8.12, you can get such an object by calling the getInstance class method. You can use this capability to evaluate the runtime of any chunk of code. All you have to do is create a Calendar object before the test code starts, create another Calendar object right after the code ends, and print out the difference in those two object’s times. To demonstrate this capability, write a short program called

Test Runtime that asks the user for a desired number of iterations, num. Then have it measure the runtime for a loop of num iterations that executes the single statement:

Math.cos(0.01 * i);

The variable i is the loop count variable.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT