I have problem on my program. Can anyone help me to fix it and explain to me a little bit?
#include <iostream>
#include <iomanip>
using namespace std;
void displayResult();
void welcomeMessage();
void game();
int main()
{
welcomeMessage();
displayResult();
displayResult(frequency, expected, intRepeats);
} // end main
void welcomemessage
{
cout << "Dice Rolling Simulation\n\n"
<< "This program allows you to simulate the rolling of a pair of dice.\n" << endl;
}
void game()
{
unsigned long x;
unsigned long modulus = 2147483647;
unsigned long multiplies = 16807;
unsigned long inciement = 0;
unsigned long intSeeds;
float num;
int intRepeats, roll;
int roll_1, roll_2;
cout << "Enter random number seed: ";
cin >> intSeeds;
cout << "Enter the number of rolls: ";
cin >> intRepeats;
x = intSeeds; //x is the PRN, the first user selected
for (int i = 0; i < intRepeats; i++)
{
x = ((multiplies * x) + inciement) % modulus;
num = x / float (modulus);
roll_1 = int (num * 6) +1;
x = ((multiplies * x) + inciement) % modulus;
num = x / float (modulus);
roll_2 = int (num * 6) +1;
roll = roll_1 + roll_2;
frequency[(roll)]++;
}
return 0;
}
void displayResult(const int arraySize, double frequency[], double expected[], int intRepeats, double exptRoll[])
{
const int arraySize = 13;
double frequency[arraySize] = { 0 };
double expected[arraySize] = {0, 0, 2.8, 5.6,
8.3, 11.1, 13.9,
16.7, 13.9, 11.1,
8.3, 5.6, 2.8};
double exptRoll [arraySize] = {0, 1.0/36, 2.0/36.0,
3.0/36.0, 4.0/36.0,
5.0/36.0, 6.0/36.0,
5.0/36.0, 4.0/36.0,
3.0/36.0, 2.0/36.0,
1.0/36.0};
cout << "\nGenerating rolls... \n " << endl;
cout << "\nFinal statistics: \n " << endl;
//Output the results of the dice rolling (sum, frequency, actual percent and expected rolls, expected percent)
cout << "" << endl;
cout << "Point" << setw(17) << "Number of Rolls" << setw(17) << "Actual Percent"
<< setw(17) << "Expected Rolls" << setw(17) << "Expected Percent" << endl;
for (int value = 2; value < arraySize; value++) //begin generating the table
{
cout << setw(5) << value ;
cout << setw(17) << static_cast<int>(frequency[value]) ;
cout << setw(16) << ((frequency[value]/intRepeats)*100) << "%" ;
cout << setw(17) << (int)(exptRoll[value-1] * intRepeats);
cout << setw(16) << setprecision (3) << expected[value]<< "%" << endl;
}
}