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

Please use Pseudocode The pseudocode below uses a random number generator and pa

ID: 3583487 • Letter: P

Question


Please use Pseudocode

The pseudocode below uses a random number generator and paralel arrays to simulate 100 rols of a pair of dce Each of the paired arrays maintains the results for one die. Develop additional ogic that wil count up and report the number of doubles that occur in the 100 simulated rols This additional ogic isto immediately follow the instructions that populate the paired arrays Note that a double occurs when the value seen on one de matches the value seen on the other, for a given roll num LIMIT -6 num die 11001. die 20100) for dice Roll 0 to 99 step 1 dielldice Roll die2ldiceRolll randomi UMIT) R your doubles counting and reporting logic goes here

Explanation / Answer

// We have a pseudocode to generate the random number from 1 to 6 and store in the current roll of die for first and second respectivly. We know doubles die occures when number appears on first die for current roll and number appears on seond die for the current roll is called doubles. We can check the doubles using if condition for each roll whose value is stored in respective die array if both value match we can increase the count ,whose initial value is assigned as 0 and it also print the message when the doubles die ocures and also display the total number of doubles occures during the 100 die roll at the last of the for loop.

the pseudo code is as follow

Start
                declare
                                num LIMIT = 6
                                num die1[100],die2[100]
                                num diceRoll
                                num CNT=0,i
                                for diceRoll =0 to 99 step 1
                                                die1[diceRoll]=random[LIMIT]
                                                die2[diceRoll]=random[LIMIT]
endfor

for i=0 to 99 step 1 // for loop to vary the value of index from 0 to 99 by ste pvalue of 1
                if die1[i] = die2[i] then // check the double die
//print the double die occure message   
      PRINT " Double Die occure at " ,(i+1) , "Roll
//increment value of count by 1
                                CNT=CNT+1
                endif
endfor
//print the total number of double die occures during the 100 Roll
PRINT " Total Double Dies are " , CNT

                                stop