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

Write a program that uses the random number generator to get the value of a die

ID: 3634345 • Letter: W

Question

Write a program that uses the random number generator to get the value of a die ( 1, 2,3,4,5,6). Use it to get values for two dice and then find the dice roll value (eg. a 6 and a 3 give a roll value of 9). Ask the user how many time they want to roll the dice. Roll the dice enough times and keep a running total of each value 2 through 12 that is rolled in an array, say called Count. After the dice are rolled and counts are set, create a parallel array, say called prob, that determines the probability(decimal value) of the roll appearing. That can be determined by dividing the count for that value by the total number of rolls made. Display the value, number of times that value ocurred , and the probability side by side on the screen.
(Note: The random number generator should have a "seed" or start value. That only needs to be done once in the program - the user can be asked to enter a number from 1 to 32767 to be used as the seed. Also, the arrays you use can be declared to be of size 13 - so that the last subscript is a 12, and when you process the loops just use loops from index 2 to index 12).

Explanation / Answer

#include #include using namespace std; unsigned int PRNG() { // our initial starting seed is 5323 static unsigned int nSeed = 5323; // Take the current seed and generate a new value from it // Due to our use of large constants and overflow, it would be // very hard for someone to predict what the next number is // going to be from the previous one. nSeed = (8253729 * nSeed + 2396403); // Take the seed and return a value between 0 and 32767 return nSeed % 32767; } int main() { // Print 100 random numbers for (int nCount=0; nCount < 100; ++nCount) { cout
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