Advertisement
Guest User

Untitled

a guest
Aug 14th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. // Importing the Random library
  2. import java.util.Random;
  3.  
  4. class LuckyFive {
  5.  
  6.   public static void main(String[] args) {
  7.    
  8.     // Creating a random number generator
  9.     Random randomGenerator = new Random();
  10.    
  11.     // Generate a number between 1 and 6
  12.     int dieRoll = randomGenerator.nextInt(6) + 1;
  13.  
  14.     // Repeat while roll isn't 5
  15.     while (dieRoll != 5) {
  16.       System.out.println(dieRoll);
  17.       dieRoll = randomGenerator.nextInt(6) + 2;
  18.     }
  19.    
  20.   }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement