Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class apples {
- public static void main(String[] args) {
- // Set up variables
- int i = 0;
- int rNum = new Random().nextInt();
- int highestNum = 0;
- // Time stuff
- double startTime = System.nanoTime();
- double endTime;
- // Loopage
- while (i < 100000) {
- System.out.println(rNum);
- i++;
- if (rNum > highestNum) {
- highestNum = rNum;
- }
- rNum = new Random().nextInt();
- }
- // End time & duration
- endTime = System.nanoTime();
- double duration = (endTime - startTime)/1000000000;
- // Print the highest number + many other things
- System.out.println("The highest number was " + highestNum);
- System.out.println("That execution took " + (duration) + " seconds!");
- }
- }
Add Comment
Please, Sign In to add comment