Itc Lab Project
Itc Lab Project
if (userChoice == 0)
{
cout << "The game ended. Thank you for playing." << endl;
break;
}
switch (userChoice)
{
case 1:
cout << "You entered: Rock" << endl;
break;
case 2:
cout << "You entered: Paper" << endl;
break;
case 3:
cout << "You entered: Scissors" << endl;
break;
default:
cout << "Invalid Input. Please enter a number between 0 and 3" << endl;
continue;
}
computerChoice = rand() % 3 + 1;
cout << "Computer choose: " << computerChoice << endl;
switch (computerChoice)
{
case 1:
cout << "Computer entered: Rock" << endl;
break;
case 2:
cout << "Computer entered: Paper" << endl;
break;
case 3:
cout << "Computer entered: Scissors" << endl;
break;
}
if ((userChoice == 1 && computerChoice == 2) ||
(userChoice == 2 && computerChoice == 3) ||
(userChoice == 3 && computerChoice == 1))
cout << "Computer wins" << endl;
else if (userChoice == computerChoice)
cout << "It's a tie" << endl;
else
cout << "You win" << endl;
}
return 0;
}