0
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

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by vchandra
0

Try to rewrite it again and then come with confusion. I tried to copy the same code and got so many errors and started fixing it but after sometime I found that it doesnt contain few but tons of errors.
code as lot of errors, braces are not closed properly, syntax is not proper.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.