compute and display the elapsed time for your computer to perform this same operations.using Java's "System.currentTimeMillis();" method to capture current time (in milli-seconds) before and after entering a loop or a method call, then subtract the earlier value from the later value to compute time difference. (code) //Fig. 7.7: RollDie.java //Die-rolling program using arrays instead of switch import java.security.SecureRandom; public class RollDie { public static void main(String[] args) { SecureRandom randomNumbers = new SecureRandom(); int[] frequency = new int[7]; // array of frequency counters // roll die 60,000,000 times; use die value as frequency index for (int roll = 1; roll <= 60_000_000; roll++) { ++frequency[1+ randomNumbers.nextInt(6)]; } System.out.printf("%s%10s%n", "Face", "Frequency"); //output each array element's value for (int face = 1; face < frequency.length; face++) { System.out.printf("%4d%10d%n", face, frequency[face]); } } }
compute and display the elapsed time for your computer to perform this same operations.using Java's "System.currentTimeMillis();" method to capture current time (in milli-seconds) before and after entering a loop or a method call, then subtract the earlier value from the later value to compute time difference.
(code)
//Fig. 7.7: RollDie.java
//Die-rolling program using arrays instead of switch
import java.security.SecureRandom;
public class RollDie {
public static void main(String[] args) {
SecureRandom randomNumbers = new SecureRandom();
int[] frequency = new int[7]; // array of frequency counters
// roll die 60,000,000 times; use die value as frequency index
for (int roll = 1; roll <= 60_000_000; roll++) {
++frequency[1+ randomNumbers.nextInt(6)];
}
System.out.printf("%s%10s%n", "Face", "Frequency");
//output each array element's value
for (int face = 1; face < frequency.length; face++) {
System.out.printf("%4d%10d%n", face, frequency[face]);
}
}
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)