The output should be a table that has the following headings:
Sum of Die, # of Rolls, Actual %, and Expected %. The # of Rolls is the number of times the Sum was rolled. Actual % is the % of # of Rolls based on 36,000 rolls. Expected % is the calculated number of time you would expect that the Sum is rolled. I don't really get it. Here is my (nonworking) code so far. Thanks for any help.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using std::cout;
using std::endl;
using std::rand;
using std::srand;
using std::time;
int main()
{
const int arraySize = 36;
int frequency[ arraySize ] = { 0 };
srand( time( 0 ));
for (int roll1 = 1; roll1 <= 36000; roll1++)
frequency[ 1 + rand() % 6 ]++;
for (int roll2 = 1; roll2 <= 36000; roll2++)
frequency[ 1 + rand() % 6 ]++;
cout << "Sum of Die" << setw( 13 ) << "# of Rolls" << endl;
for (int face1 = 1; face1 < arraySize; face1++)
cout << setw( 4 ) << face1 << setw( 13 ) << frequency[ face1 ] << endl;
for (int face2 = 1; face2 < arraySize; face2++)
cout << setw( 4 ) << face2 << setw( 13 ) << frequency[ face2 ] << endl;
return 0;
} // end main
This post has been edited by James Bond C++ Spy: 08 November 2007 - 01:46 PM

New Topic/Question
Reply


MultiQuote




|