Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. //Name: Jeremy Goh
  2. //Class: 1T04
  3. //Work: Practical 4
  4.  
  5. import java.util.*;
  6. public class Craps
  7. {
  8.     public static void main (String[] args)
  9.     {
  10.         Scanner input = new Scanner(System.in);
  11.         double dice1, dice2, totaldice;
  12.           dice1 = (int)(6 * Math.random() + 1);
  13.           dice2 = (int)(6 * Math.random() + 1);
  14.           totaldice = dice1 + dice2;
  15.         System.out.println("Dices add up to: " + totaldice);
  16.           if( totaldice == 7 || totaldice == 11)
  17.         {
  18.             System.out.println("You LOSE");
  19.                 System.out.println("Game over!");
  20.                 }
  21.         else if( totaldice == 2 || totaldice == 3)
  22.           {
  23.                 System.out.println("Congrats!");
  24.                 System.out.println("You won!");
  25.             }
  26.           else if(totaldice == 12)
  27.           {
  28.                 System.out.println("Draw!");
  29.                 System.out.println("Begin the game again!");
  30.           }
  31.           else
  32.           {
  33.                 System.out.println("Roll Again!");
  34.                 System.out.println("All the best!");
  35.             }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement