Question

Write a Java pseudocode for a 2-dice game. This game will roll the two dice together...

Write a Java pseudocode for a 2-dice game. This game will roll the two dice together for 100 times. In each time, it will display the face values from both dice. The program will count how many times (out of these 100 attempts) did the two dice generate a total point of 10 or above, and display the result at the end. In a word document, PPT file or a PDF file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Java Pseudocode to roll 2 die 100 times and count the number of times the two dice generate a total point of 10 or above,
Declaration
   // declare integer variables to store the face values for the 2 dice
   int die1, die2;
   int count, i; // variables to count and loop variable
   Random ran; // object of Random class to generate random integers
Start
  
   // set count to 0
   count = 0;
   ran = new Random(); // create a new object of Random class
  
   // loop 100 times
   for(i=0;i<100;i++)
   {
       // nextInt generates a random integer between 0 to (n-1) (inclusive) where n is the argument of nextInt
       // here it generates an integer between 0 and 5 (inclusive) , and 1 is added to the result to generate a number between 1 and 6(inclusive)
       // generate the face value for the 2 dice
       die1 = ran.nextInt(6) + 1;
       die2 = ran.nextInt(6) + 1;
       // display the face values
       Print die1, die2;
       // check if sum of the face values >= 10, then increment the count by 1
       if((die1 + die2) >= 10)
           count = count + 1;
   }
   // display the count
   Print count;
End  
  

Add a comment
Know the answer?
Add Answer to:
Write a Java pseudocode for a 2-dice game. This game will roll the two dice together...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a flowchart for a 2-dice game. This game will roll the two dice together for...

    Write a flowchart for a 2-dice game. This game will roll the two dice together for 100 times. In each time, it will display the face values from both dice. The program will count how many times (out of these 100 attempts) did the two dice generate a total point of 10 or above, and display the result at the end. In a word document, PPT file or a PDF file.

  • Create a Dice Game: PYTHON This game is between two people. They will roll a pair...

    Create a Dice Game: PYTHON This game is between two people. They will roll a pair of dice each 10 times. Each roll will be added to a total, and after 10 rolls the player with the highest total will be the Winner! You will use the RANDOM class RANDRANGE to create a random number from 1 to 6. You'll need a function for "rollDice" to roll a pair of dice and return a total of the dice. You must...

  • Please i need helpe with this JAVA code. Write a Java program simulates the dice game...

    Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...

  • Java programming Write a simulation of the Craps dice game. Craps is a dice game that...

    Java programming Write a simulation of the Craps dice game. Craps is a dice game that revolves around rolling two six-sided dice in an attempt to roll a particular number. Wins and losses are determined by rolling the dice. This assignment gives practice for: printing, loops, variables, if-statements or switch statements, generating random numbers, methods, and classes. Craps game rules: First roll: The first roll (“come-out roll”) wins if the total is a 7 or 11. The first roll loses...

  • ( Java Programming ) Write an application to simulate the rolling of two dice. The application...

    ( Java Programming ) Write an application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12...

  • The Dice game of "Pig" can be played with the following rules. 1. Roll two six-sided dice. Add the face values...

    The Dice game of "Pig" can be played with the following rules. 1. Roll two six-sided dice. Add the face values together. 2. Choose whether to roll the dice again or pass the dice to your opponent. 3. If you pass, then you get to bank any points earned on your turn. Those points become permanent. If you roll again, then add your result to your previous score, but you run the risk of losing all points earned since your...

  • Write a java program that simulates the rolling of four dice. The program should use random...

    Write a java program that simulates the rolling of four dice. The program should use random number generator to roll dice. The sum of the four values should then be calculated. Note that each die can show an integer value from 1 to 6, so the sum of the four values will vary from 4 to 24, with 14 being the most frequent sum and 4 and 24 being the least frequent sums. Your program should roll the dice 12,960...

  • Problem 9 A single game of craps (a dice game) consists of at most two rolls...

    Problem 9 A single game of craps (a dice game) consists of at most two rolls of a pair of six sided dice. The ways to win are as follows: Win-the first roll of the pair of dice sums to either 7 or 1 (you win, game over, no second roll Win the first roll of the pair of dice does NOT sum to either 7 or 1 but the sum of the second roll is equal to the sum...

  • 1. Problem Description Language: JAVA The game of Poker Dice is a bit like standard poker...

    1. Problem Description Language: JAVA The game of Poker Dice is a bit like standard poker but played with dice instead of cards. In this game, five fair dice are rolled. We will recognize one of seven different hands, in order of increasing value: None alike: Five distinct die values occur. Example: 1, 3, 4, 5, 6 One Pair: Four distinct die values occur; one die value occurs twice and the other three die values occur once each. Example: 1,...

  • 2. Roll two fair dice. (a) How many possible outcomes are there? (b) What probability would...

    2. Roll two fair dice. (a) How many possible outcomes are there? (b) What probability would be assigned to each of the outcomes in the sample space? (c) List all possible outcomes. Use the notation (# on face on first die, # on face on second die), to indicate the result of a roll of the dice. (3.2.4)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT