Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Name: Jeremy Goh
- //Class: 1T04
- //Work: Practical 4
- import java.util.*;
- public class Craps
- {
- public static void main (String[] args)
- {
- Scanner input = new Scanner(System.in);
- double dice1, dice2, totaldice;
- dice1 = (int)(6 * Math.random() + 1);
- dice2 = (int)(6 * Math.random() + 1);
- totaldice = dice1 + dice2;
- System.out.println("Dices add up to: " + totaldice);
- if( totaldice == 7 || totaldice == 11)
- {
- System.out.println("You LOSE");
- System.out.println("Game over!");
- }
- else if( totaldice == 2 || totaldice == 3)
- {
- System.out.println("Congrats!");
- System.out.println("You won!");
- }
- else if(totaldice == 12)
- {
- System.out.println("Draw!");
- System.out.println("Begin the game again!");
- }
- else
- {
- System.out.println("Roll Again!");
- System.out.println("All the best!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement