1 public class Solution 2 { 3 public static void main(String[] args) 4 { 5 int n1 = (int)(Math.random() * 5 + 1); 6 int n2 = (int)(Math.random() * 5 + 1); 7 8 diceGame(n1, n2); 9 }10 11 public static void diceGame(int n1, int n2)12 {13 if(n1 + n2 == 2 || n1 + n2 == 3 || n1 + n2 == 12)14 {15 System.out.println("You rolled " + n1 + " + " + n2 + " = " + (n1 + n2));16 System.out.println("You win");17 }18 else if(n1 + n2 == 7 || n1 + n2 == 11)19 {20 System.out.println("You rolled " + n1 + " + " + n2 + " = " + (n1 + n2));21 System.out.println("You lose");22 }23 else24 {25 int sum = n1 + n2;26 System.out.println("You rolled " + n1 + " + " + n2 + " = " + (n1 + n2));27 System.out.println("The point is " + (n1 + n2));28 29 int num1;30 int num2;31 32 while(true)33 {34 num1 = (int)(Math.random() * 5 + 1);35 num2 = (int)(Math.random() * 5 + 1);36 37 System.out.println("You rolled " + num1 + " + " + num2 + " = " + (num1 + num2));38 if(num1 + num2 == 7)39 {40 System.out.println("You lose");41 break;42 }43 44 else if(num1 + num2 == sum)45 {46 System.out.println("You win");47 break;48 }49 50 sum = num1 + num2;51 }52 }53 }54 }