public
anonymous / gist:7164487
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.