*This is an assignment*
*instructions for original assignment attached*
Ok, I am trying to get the program to calculate the number of times one goes broke and the number of time one reaches the goal. I want the program to run a number of trails, originally it was going to be 1000, but I kept it short for testing.
Can anyone explain what I am doing wrong I know it has to do with the mess of a loop that I have created. Also any advice?
Thanks in advance.
Again Thanks.Code:#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(NULL)); // Seed the RNG once, at the start of the program
int n, m, flip, trial;
int broke = 0;
int goal = 0;
cout << "Gamblers' Ruin" << endl;
cout << "Please enter the amount of money you wish to bet." << endl;
cin >> n;
cout << "You entered $" << n << " dollars." << endl;
cout << endl;
cout << "Please enter the goal amount you wish to quit at." << endl;
cin >> m;
cout << "You entered: " << m << endl;
cout << endl;
for (trial = 1; trial <= 100; trial++)
{
while(n == 0 || n != m)
{
if(rand()%2 == 0)
{
cout << "Heads" << endl;
n++;
cout << endl;
}
else
{
cout << "Tails" << endl;
n--;
cout << endl;
}
cout << n;
cout << endl;
}
if (n == 0)
{
broke++;
}
else if (n == m)
{
goal++;
}
}
cout << broke;
cout << endl;
cout << goal;
cout << endl;
system("pause");
return 0;
}

