Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2017Summer

06.05.17 - 07.30.17

C Language

CSCI2473

Tuesday Thursday
09:30 AM - 12:20 PM

Dice Roller

Lab06

Objective: To practice using arrays

pastdue

Submit Your Solution

Lab06

Request a Copy of your Solution

Lab06

Requirements

Program compiles and runs with no errors or warnings10 pts
Program allows input of sides and provides correct error checking of the input15 pts
Program correctly calculates and displays the possible totals25 pts
Program correctly calculates and displays the calculated odds for each total25 pts
Program correctly calculates and displays the actual roll total percentages25 pts
Total100 pts

Instructions

Overview

For this lab you will create a C program that will display all of the possible totals that can be rolled using two dice of a specified number of sides, the odds of rolling each of those totals, the actual percentage of time that each total was rolled after 36,000 attempts.

Inputs

For this lab the dice that are rolled will have a number of sides specified by the user. Prompt the user for the number of sides for this dice and accept any integer value between 2 and 100 inclusively.

Processing

With the number of sides from the user determine all of the possible totals that can be rolled using two dice with that number of sides. For example, two 6 sided dice could produce totals between 2 and 12.

Next, calculate the odds of rolling each of those totals as a percentage. Dice should not actually be rolled to find these odds.

Finally, roll two simulated dice 36,000 times and track how often each total is actually rolled. Calculate the actual percentage of each total for later display.

We can simulate rolling dice in C by using a random number generator, see attached program for an example of doing this.

Output

The program should produce 3 columns of output, see attached file for an example. The possible totals should be displayed to the user as a first column of output, the calculated odds of rolling each total should be displayed as a second column of output, and the actual percentage of times each total was rolled should be shown as the third column of output.

Summary

If C's random number generator is producing good pseudo-random numbers there should be a strong similarity between the calculated odds of rolling each total and the actual number of times each total was rolled.

Extras