#include<iostream>
#include<cstdlib>
#include<ctime>
#include<string>
using namespace std;
int main()
{
char replay;
int userInput;
cout<< "Let's play Rock, Paper, Scissors"<<endl;
do
{
cout<<"Enter 1 for Rock, 2 for Paper, 3 for Scissors"<< endl;
cin>> userInput;
switch(userInput)
{
case 1:
cout <<"You chose rock" << endl;
break;
case 2:
cout <<"You chose paper" <<endl;
break;
case 3:
cout <<"You chose scissors" << endl;
break;
default:
cout << userInput << " is not a valid choice"<< endl;
break;
}
cout<<"Would you like to play again (Y for yes, N for no)?"<<endl;
cin >> replay;
} while((replay=='Y') || (replay=='y'));
return 0;
}
When I enter in a character in my answer for entering a number and when I'm asked if I want to play again and I enter in a character that isn't Y, y, N, or n it goes into an infinite loop