Computer Science Java

posted by .

I have to write program for a dice game and use a boolean variable in the application class of the dice game that equals true when snake eyes, doubles, and box cars have been meet. I am having a little trouble doing that in my application class so I was wondering if somebody can help me out. This is how my application class looks now:

package classes;

public class DiceGameApp {

public static void main (String [] args) {

DiceGame dice = new DiceGame ();

for (int rollCount = 0; rollCount < 10; rollCount ++) {


System.out.println("\nYou rolled a " + dice.getDieone()+ " for dice one and a " +dice.getDietwo()+ " for dice two.");

if(dice.getDieone()== 1 && dice.getDietwo()== 1){

System.out.println ("\nYou have rolled snake eyes.");
if (dice.getDieone()== 6 && dice.getDietwo()== 6)

System.out.println("\nYou have rolled boxcars.");


System.out.println("\nYou have rolled doubles.");



  • Computer Science Java -

    A Boolean variable is a variable, like an int or a string, but whose value is either "true" or "false".

    Try this little lump of code, and vary d1 and d2 values, to see the effect:

    int d1 = 1
    int d2 = 1

    boolean snakeeyes;
    boolean doubles;
    boolean boxcars;

    snakeeyes = (d1 + d2 == 2);
    doubles = (d1 == d2);
    boxcars = (d1 + d2 = 12);

    System.out.println("Is this snake-eyes?");

    // and you can also use it in a logical statement
    System.out.println("Is this bpxcars?");
    if (boxcars) System.out.println("Yes");

    and so on.

    It's not clear from your description whether your project calls for one boolean condition for each condition or one for any of them, but I hope this example will illustrate the general method.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. English expression

    Playing the dice game, write down suitable responses and have a conversation. (They work in pairs playing the dice game. However, they use just one die.) You work in pairs. One student should throw the die. If it has one, he should …
  2. English expression

    There is only one die in playing the dice game. They are supposed to work in pairs in the dice game. Which expressions are correct?
  3. English

    Playing the dice game, have a conversation about what you must do and what you must not do at each place. After that write down the rules as in the example. You should work in pairs. One should roll the dice and according to the number …
  4. English

    Roll the dice. If you get 3 on the face of the dice, move forward for 3 spaces. Roll the dice. If you have 3 on the face of the dice, move forward for 3 spaces. Roll the dice. If you get Number 3 on the face of the dice, move forward …
  5. Mathematics for Liberal Arts

    You are on a TV show. You have been asked to either play a dice game five times or accept a $50 bill. The dice game works like this: If you roll a 1, 2 or 3, you win $46. If you roll a 4 or 5, you lose $22. If you roll a 6, you lose …
  6. Programming Logic

    I need to create a flowchart/psuedocode for a dice game that give you 2 rolls with 5 dice, 3 rolls per game. the computer will roll the 4 dice and calculate your score. my question i need to repeat this 3 times and can i use …
  7. Algebra

    You are a contestant on a game show and have the chance to win a car by rolling 5 dice. Each die has three sides that say CAR and three sides that are blank. In order for you to win the car you CAR on all five dice. You have three …
  8. Help me please Maths

    Calvin is playing a game of Dungeons and Dragons. In order to make it across the river, he needs to throw six 4-sided dice, and have their sum be a multiple of 5. How many different dice throws result in Calvin making it across the …
  9. Math

    At this year's State Fair, there was a dice rolling game. If you rolled two dice and got a sum of 2 or 12, you won $20. If you rolled a 7,you won $5. Any other roll was a loss. It cost $3 to play one game with one roll of the dice. …
  10. Prob

    A game is played using three 6-sided dice. You throw these dice one time and if the dice all show the same number ( triples), you win $ 40.00 . For this game to be “fair”, how much should a person pay to play this game ?

More Similar Questions