SHARE
TWEET

Untitled

a guest Aug 14th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top