I need to compile a Rock Paper Scissors program in C++ that uses an algorithm th
ID: 643106 • Letter: I
Question
I need to compile a Rock Paper Scissors program in C++ that uses an algorithm the following algorithm and shell:
The algorithm for the Rock, Paper, Scissors game is as follows:
1) The computer selects either Rock (R), Paper (P), or Scissors (S).
2) The player chooses either R, P, or S. If the player enters anything else, he/she is prompted again to enter either R, P, or S, until valid input is entered
3) The program determines and declares one of the following:
"Scissors cuts paper, the player wins!"
Explanation / Answer
#include #include #include using namespace std; char rps_computer(); char rps_player(); void output(char player, char computer); bool play_again(); int main() { srand(time(NULL)); char computer, player; do { computer = rps_computer(); player = rps_player(); output(player, computer); } while (play_again()); } void output(char p, char c){ if (p == c){ coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.