I was working on this C++ homework assignment, and when I tried to execute, the .exe file kept "Not Responding." I closed the program and Codeblocks. When I tried to open another program I know works to re-start my assignment and try again, Codeblocks stopped working. Now when I try to open it, it keeps saying "Not Responding."
Program is supposed to roll 2 dice for the user, user decides if they want to keep the dice amount or not, and once the user is done with their final roll, it is supposed to compare the user's final roll total to the computer's roll total -- whoever is higher wins.
My program returns no errors...but it will not work when trying to execute...and now I am worried I have a corrupted file or something that made Codeblocks stop working. Any ideas what is going on and how I can get Codeblocks to run properly again?
Here is the program:
#include <iostream>
#include <cstdio>
#include <time.h>
#include <stdlib.h>
using namespace std;
int main()
{
srand(time(0));
int Roll1, Roll2, UserRoll, Roll3, Roll4, ComputerRoll;
char Hold;
char PlayAgain;
do
{
Roll1 = 1+(rand()%6);
Roll2 = 1+(rand()%6);
UserRoll = Roll1 + Roll2;
do
{
cout << "Beat the computer!" << endl;
cout << "" << endl;
cout << "You rolled a " << Roll1 << " and a " << Roll2 << "(total= " << UserRoll << ")" << endl;
cout << "" << endl;
cout << "Do you want to keep those? (Y/N): " << endl;
cin >> Hold;
if (Hold == 'N')
{
cout << "Rolling again! " << endl;
}
} while (Hold == 'N');
if (Hold == 'Y')
{
cout << "You chose to keep your numbers. Your total is: " << UserRoll << endl;
} break;
} while (true);
do
{
Roll3 = 1+(rand()%6);
Roll4 = 1+(rand()%6);
ComputerRoll = Roll3 + Roll4;
do
{
cout << "" << endl;
cout << "The computer rolled a " << Roll3 << " and a " << Roll4 << endl;
cout << "" << endl;
cout << "(total= " << ComputerRoll << ")" << endl;
if (ComputerRoll < UserRoll)
{
cout << "Congratulations, you win! " << endl;
}
break;
if (ComputerRoll > UserRoll)
{
cout << "Sorry, you lose. " << endl;
}
break;
if (ComputerRoll == UserRoll)
{
cout << "You tied. " << endl;
}
break;
} while (true);
} while (true);
return 0;
}