Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program 1 – Rock, Paper, Scissors This program is to refresh memories and abilit

ID: 3783051 • Letter: P

Question

Program 1 – Rock, Paper, Scissors This program is to refresh memories and abilities to program in C. Even though this class focuses on C++ as a programming language, C is an integral part of C++. In this program, the student will program “Rock, Paper, Scissors” in C. The game has the following rules: 1. The player chooses between Rock, Paper, and Scissors to play against the computer. 2. The Computer randomly picks Rock, Paper, or Scissors to play against the player. 3. Rock crushes Scissors 4. Scissors cuts Paper 5. Paper covers Rock 6. If the player and computer play the exact same thing, it is considered a tie. The student programmer will be provided with the following snippet of code: The student programmer’s job is to write the functions int play_game(int *) and int menu(int *). The student programmer will also update the Comment Header at the top of pgm1.c. DO NOT: 1) Modify the main function 2) Add global variables. int menu(int *): Receives: integer array score Returns: Menu number for Rock, Paper, Scissors, or Exit. Returns -1 for any other number than applicable menu choice Grading: 1) Displays “ROCK PAPER SCISSORS!” at the top of the menu 2) Displays the current score between the player and the computer (including ties) 3) Displays choice numbers for Rock, Paper, Scissors, and Exit. 4) Asks for a choice – If improper choice is given (alpha-numeric and wrong number), asks for another choice 5) Console Display is organized and easily read 6) Code is organized and easily read (Comments where needed) HINT: Use of a switch statement makes the code a little easier to read. int play_game(int *): Receives: integer array score Returns: an index of score to be incremented. If the player wins, returns 0. If the computer wins, returns 1. If there is a tie, returns 2. Grading: 1) The computer choice is randomly generated between 3 numbers using rand(). 2) Displays BOTH the User choice and the Computer Choice 3) Displays whether the result is a win, loss, or tie for the User. 4) Displays the following statements depending on what was played by the User and Computer “ROCK CRUSHES SCISSORS!” “SCISSORS CUT PAPER!” “PAPER COVERS ROCK!” “TIE – BAZINGA!” 5) Returns 0 if the User won, 1 if the Computer won, and 2 if the User and Computer Tied. DELIVERABLES: 1) pgm1.c 2) makefile (no extension) NOTE: This program must compile using MinGW compiler used in the class. Points will be deducted if the program does not compile using MinGW. BONUS (+ 10 Pts): Incorporate the options Lizard and Spock from the game “Rock Paper Scissors Lizard Spock” made popular from CBS sitcom The Big Bang Theory. The outcomes are as follows: Scissors cuts Paper Paper covers Rock Rock crushes Lizard Lizard poisons Spock Spock smashes Scissors Scissors decapitates Lizard Lizard eats Paper Paper disproves Spock Spock vaporizes Rock Rock crushes Scissors

Explanation / Answer

Answer:

#include <iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;
int main()
{
   do{
       string playerOption;

       int system;

       cout << "Are you ready to play Rock, paper, or scissors? " << endl;
       cout << " " << endl;

       cin >> playerOption;

       cout << "Your entry: " << playerOption << endl;
       cout << " " << endl;

       srand(time(NULL));

       system = rand() % 10 + 1;


       if (system <= 3)
       {

           cout << "system entry: Rock" << endl;
           cout << " " << endl;

       }

       else if (system <= 6)
       {

           cout << "system entry: Paper" << endl;
           cout << " " << endl;

       }
       else if (system >= 7)
       {

           cout << "system entry: Scissors" << endl;
           cout << " " << endl;

       }

  
       if (playerOption == "rock" && system <= 3)
       {

           cout << "It's a tie!" << endl;
           cout << " " << endl;

       }
       else if (playerOption == "rock" && system <= 6)
       {

           cout << "You lose!" << endl;
           cout << " " << endl;

       }
       else if (playerOption == "rock" && system >= 7)
       {

           cout << "You won the game" << endl;
           cout << " " << endl;

       }

       if (playerOption == "paper" && system <= 3)
       {

           cout << "You won the game" << endl;
           cout << " " << endl;

       }
       else if (playerOption == "paper" && system <= 6)
       {

           cout << "It is a tie" << endl;
           cout << " " << endl;

       }
       else if (playerOption == "paper" && system >= 7)
       {

           cout << "You lost the game" << endl;
           cout << " " << endl;

       }
      
       if (playerOption == "scissors" && system <= 3)
       {

           cout << "You lost the game" << endl;
           cout << " " << endl;

       }
       else if (playerOption == "scissors" && system <= 6)
       {

           cout << "You won the game" << endl;
           cout << " " << endl;

       }
       else if (playerOption == "scissors" && system >= 7)
       {

           cout << "It is a tie" << endl;
           cout << " " << endl;

       }
   } while (cin.get());
   cin.get();
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote