import java.util.*;
public class Dice {
public static void main(String[] args) {
String strInput;
Scanner console = new Scanner(System.in);
System.out.print(" Please enter desired sum: ");
do {
Random r = new Random();
int count = 0;
int dice1 = 0;
int dice2 = 0;
a = random number;
b = random number;
while (!console.hasNextInt()|| or sum >= 2 || sum <= 12){
int input = console.nextInt();
print("")
console.nextline();
}
dice1 = r.nextInt(6) + 1;
dice2 = r.nextInt(6) + 1;
System.out.println("dice1 + "and " + dice2 + " = " + (dice1 + dice2));
count++;
} while (dice1 + dice2)! = input
while (!console.hasNextInt()) {
console.nextLine();
System.out.println("Invalid sum. Please re-enter desired sum: ");
System.out.print("Please enter desired sum: ");
}
}
int input = console.nextInt();
return console.nextInt();
I dont know how to fix it, any help would be nice.
This is what it should do, prompt for a desired sum, then repeatedly simulates the rolling of two six-sided dice until their sum is the desired sum. If the user enters an invalid value, issue the following message:
Invalid dice sum. Please re-enter the desired dice sum:
Here is a sample dialog with the user:
Desired dice sum: 9
4 and 3 = 7
3 and 5 = 8
5 and 6 = 11
5 and 6 = 11
1 and 5 = 6
6 and 3 = 9