I have an assignment for my beginner's programming class to create a craps program, I have finished the code and it will build successfully, but when I try to debug to test it VC++ acts like the console is open and nothing happens. I have tried using my second computer thinking the issue might be with my computer but had the same error. What could be keeping me from running my program?
#include <iostream>
usingnamespace std;
#include <cstdlib>
#include <ctime>
int rollDice( void );
int main()
{
char response;
enum Status { CONTINUE, WON, LOST };
int sum, myPoint;
Status gameStatus;
int bank=50, bet;
cout << "You have $50 \n\n";
do
{
cout << "Place your bet: ";
cin >> bet;
if (bet > bank)
{
cout << "You can't bet more then you have in the bank. Bet again!\n";
cout << "Enter your new bet now: ";
cin >> bet;
}
srand ( (unsignedint)time(NULL) );
sum = rollDice();
switch ( sum )
{
case 7:
case 11:
gameStatus = WON;
bank += bet;
cout << "You have $" << bank << endl;
break;
case 2:
case 3:
case 12:
gameStatus = LOST;
bank -= bet;
cout << "You have $" << bank << endl;
break;
default:
gameStatus = CONTINUE;
myPoint = sum;
cout << "Your point for this game is " << myPoint << " . Roll Again." << endl;
break;
}
while ( gameStatus == CONTINUE )
{
sum = rollDice();
if ( sum == myPoint )
{
gameStatus = WON;
bank += bet;
cout << "You won by making point\n";
cout << "You have $" << bank << endl;
}
else
{
if ( sum == 7 )
{
cout << "You rolled a 7. You lost\n";
}
gameStatus = LOST;
bank -= bet;
cout << "You have $" << bank << endl;
}
}
if ( gameStatus == WON )
{
cout << "Player wins, would you like to play again? [y/n]" << "\n";
cin>>response;
}
else
{
cout << "Player lose, would you like to play again? [y/n]" << "\n";
cin>>response;
}
}
while(response=='y');
return 0;
}
int rollDice( void )
{
int die1, die2, workSum;
die1 = 1 + rand() % 6;
die2 = 1 + rand() % 6;
workSum = die1 + die2;
cout << "Player rolled " << die1 << " + " << die2
<< " = " << workSum << endl;
return workSum;
}