I am new to programming in DEV-C++ so I ran in to a few problems with my code, I am trying to create a number guessing game if you run my code its working well but I also need to have an option of "PLAY AGAIN" at the end which will restart a program with a new random number and also need to have an error trapping so it will only allow me to input numerical values. If you could help I would appreciate that. Thank you!!!
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int level;
int guess;
int randn;
int chances=3;
system("title Advanced Number Guessing Game");
system("color 5");
cout<<"Welcome to the Advanced Number Guessing Game!!\n"<<"**********************************************\n";
cout<<"\n1)Easy (1-10)\n";
cout<<"2)Medium (1-20)\n";
cout<<"3)Hard (1-30)\n";
cout<<"\nChoose level of difficulty:";
cin>>level;
switch (level)
case (1):
srand(time(0));
randn= rand()% 10 + 1;
system("cls");
do
{
cout<<"Please enter a number between 1 and 10 (including 1 and 10):";
cin >> guess;
chances--;
if(guess == randn)
cout << "\nTHAT IS CORRECT!! YOU WIN!! \n"<<"Thank you for playing the Number Guessing Game!\n";
else if (chances == 0)
cout << "\nSorry, you did not guess the number. You Lose!!\n"<<"The correct number was \n"<<randn;
else
{
if (guess!=randn && guess>randn)
cout << "Sorry, thats too high. Please try again. You have "<<chances<<" more chances:\n";
if (guess!=randn && guess<randn)
cout << "Sorry, thats too low. Please try again. You have "<<chances<<" more chances:\n";
}}while(chances>0 && guess!=randn);
system("PAUSE");
return EXIT_SUCCESS;
}