Skip to content

anonymous /gist:7164487
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int GetUserChoice()
{
int choice;
cout << "Please select one of the following options:" << endl;
cout << "1. Rock" << endl;
cout << "2. Paper." << endl;
cout << "3. Scissors" << endl;
cout << " or " << endl;
cout << "4. Quit " << endl;
cout << "Your choice is: ";
cin >> choice;
cout << endl;
if ( choice == 1 )
{
cout << "You chose rock." << endl;
}
else if ( choice == 2 )
{
cout << "You chose paper." << endl;
}
else if ( choice == 3 )
{
cout << "You chose scissors." << endl;
}
else if ( choice == 4 )
{
cout << "You quit. Thank you for using the program." << endl;
}
else if ( choice > 4 || choice < 1 )
{
cout << "Please enter a valid choice\n" << endl;
}
return choice;
}
int main()
{
PrintNameHeader();
int choice = 1;
do
{
int choice = GetUserChoice();
}while ( choice != 4);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.