0

Hey guys, im just learning how to use methods but I really cant seem to understand them.

We have a question where we have to write a program for the following game.

There is a little known dice game which is played with a pair of dice and has the following rules: the player keeps rolling the dice until the total on the dice is 2, 3, 7, 11 or 12. If the total is 7, then the player loses, if it's 2, 3, 11 or 12 then the player wins. If the total is any other number, then the game continues.

Im really stuck in the mud as I have no idea how to write a method that will only return if the values match the ones above.

Any help would be great!

Thank you

David

Code so far below

```
public class DiceGame
{
static int random(int low, int high)
{
int random = (int)(Math.random() * (high - low) + low + 1);
return random;
}
public static void main(String args [])
{
System.out.println("Would you like to play the game? (y/n) ");
String responseLine = Console.readString();
char response = responseLine.charAt(0);
if(response == 'y')
{
for(int i = 0; i <= 10; i ++)
{
int low = 1;
int high = 6;
System.out.println("The dice are cast young one ");
System.out.println("The total is: ");
System.out.println(random(low,high) + random(low,high));
}
}
}
}
```

*Edited
by mike_2000_17*: Fixed formatting