Advertisement
RazorBlade57

Dice Roll

Sep 11th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class DiceRoll {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Random r = new Random();
  8.         int result = r.nextInt(6);
  9.        
  10.         result = result + 1;
  11.        
  12.         System.out.println("You rolled a " +result);
  13.        
  14.         {
  15.        
  16.             //If the number is odd, you loose, if the number is even    
  17.         if ((result) % 2 == 0)
  18.            
  19.         System.out.println("You won!");
  20.        
  21.         else
  22.        
  23.         System.out.println("You loose :(");
  24.         }
  25.        
  26.  
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement