Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Please read the following program and describe the functionality of the progr

ID: 3563558 • Letter: 2

Question

2. Please read the following program and describe the functionality of the program import java util Scanner public class Rolling Dice public static void main(Stringll args) int counter boolean islinish false; g the D System Start R ce n") do f System Print Thi is your %d time play Counter int first (int) (6*Math. rando 1 int second (int) (6*Math dom (O) +1 int sum first second: if(sum 10) System ("Excellent") Syste Pr Your throws are: %d t%d n", first, second): else if(sum 6) System ("Good") rintln System aur. r throws are: %d t%d n", first, seco else System ou println Do it one more time System ("Your throws are: %d t%d n", first, second): ntfi tln("Do System it again m/N)?") want to print Scanner sc new Scanner System String answer sc.nextLinco; if answer equals one Case ("Y")) is Finish false; else isFinish true counter System. while(!is Finish); tln("Game over" System.out.print

Explanation / Answer

Functionality:

Based on program

one person is actually throwing two dice at one time

if sum of two dice is greater than 10 then its printing EXCELLENT

if sum of two dice is greater than 6 then its printing GOOD

if they above both conditions fail its printing DO IT ONE MORE TIME

and it will ask if u want to play again

if you say YES based on scanner it will then isFinish set to false and while loop executes again

otherwise it come out of loop and print game over

Math.random() : it returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0

since one dice value does not exceed 6 they are multiplying it with 6 and taking integer

so possibilities are : 1,2,3,4,5,6

its measuring the sum and based on that judging the answer if you are EXCELLENT or GOOD or DO IT ONE MORE TIME

Feel free to ask any question you dont understand in that program

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote