Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

step by step explanation please Develop a Java program for a 3-dice game. This program simulates a three dice game, in which a player throws

step by step explanation please
image text in transcribed
image text in transcribed
image text in transcribed
Develop a Java program for a 3-dice game. This program simulates a three dice game, in which a player throws three dice together and eam points depending on the face values received in each attempt. - If the face values got from three dice are all different, the player gets points as the sum of the three face values. E.g., if the three dice values are 1, 3, 5, the player gets 9pts as the result of 1+3+5 - If two of the dice got the same face value, the player gets double points from the sum of the three face values. E.g., if the three dice values are 2,2,5, the player gets 18 pts as the result of (2+2+5)2. - If all the face values from the three dice are the same, the player gets triple points from the sum of the three face values. E.g., if the three dice values are 3,3,3, the player gets 27pts as the result of (3+3+3)3. - If the points get from one attempt of three dice rolling is over 25 , it blasts and the player doesn't get any point in this round. E.g., in the above three examples, the player will get 9 points from example 1, 18 points from example 2, but no point from example 3 since it was over 25 . This program allows a player to throw the three dice 10 times. In each rolling attempt, the program will display the three dice values, and shows if it is blasted or safe and how many points eamed from this attempt. Then it goes to the next dice rolling attempt. The points earned from the 10 dice rolling attempts will be cumulated into the game total, and after all 10 times, this program displays the game results, including how many times it blasts, and what is the total points that the player gains in this game. 1. Develop a flow chart for this problem. (7 pts) Suggestion: - You can start from a simple version of flowchart. It may take a few rounds of modification to get good ones. - This program includes sequence structure, selection structure and repetition structure. Make sure you show them clearly. - For the repetition actions, always think of what to do in one loop, like how will happen when the player throws the three dice for one time. Draw the flowchart for this part first, and then think about how to show the repetition of this part for 10 times. - Make sure the texts on the shapes, and labels like true and false on the arrows are clear to read. - You can use hand drawing, Word, PPT, Visio, LucidChart, etc. Make sure the final submission has to be a png/jpeg, PPT file or a PDF. 2. Write a Java program for this 3 -dice game. This game will roll the three dice together for 10 times (i.e., a repetition structure), In each time, it will a. Display the face values from the three dice. b. Decide how to calculate the total points from the three dice face values. (A) selection structure) c. Decide if it is blasted, so no point to earn, or otherwise, earn the points to the game. total (A selection structure) After 10 times of dice rolling, this program displays game output including the number of blasts and total point earned in the game. See the execution example above. (10 pts) Requirements: a) Your class should be named ThreeDiceGame, and your java file should be named ThreeDiceGame.java. b) Pseodocode: you shoukd start your java file by providing the class and method blocks with i1. indentation, and comment lines for major tasks in the program. c) In this question, use the Random class and its object to simulate dice rolling. Make sure your dice will generate integer values in the range of I - 6 . d) This question doesn't take user input, thus doesn't really need Scanner class and object. But the program usually generates random values and do all 10 rolling attempts very fast. To slow it down for the users and for you to check the result from cach rolling attempt, you could PRETEND to take user input before each dice rolling affempt. That means, you can still import Scanner and create a Scanner object. You can use a statement like: input, nextLine ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions