Guest User

Untitled

a guest
Jan 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class apples {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         // Set up variables
  8.         int i = 0;
  9.         int rNum = new Random().nextInt();
  10.         int highestNum = 0;
  11.        
  12.         // Time stuff
  13.         double startTime = System.nanoTime();
  14.         double endTime;
  15.        
  16.         // Loopage
  17.         while (i < 100000) {
  18.             System.out.println(rNum);
  19.             i++;
  20.            
  21.             if (rNum > highestNum) {
  22.                 highestNum = rNum;
  23.             }
  24.            
  25.             rNum = new Random().nextInt();
  26.         }
  27.        
  28.         // End time & duration
  29.         endTime = System.nanoTime();
  30.         double duration = (endTime - startTime)/1000000000;
  31.        
  32.         // Print the highest number + many other things
  33.         System.out.println("The highest number was " + highestNum);
  34.         System.out.println("That execution took " + (duration) + " seconds!");
  35.     }
  36. }
Add Comment
Please, Sign In to add comment