Question: 2.2 Write C++ program that randomly generates either an integer from 1 to 5 ora character from A to E. The program then prompts the

2.2 Write C++ program that randomly generates either an integer from 1 to 5 ora character from A to E. The program then prompts the user to guess the number or the character Your program must have the following modules: A void function (C++) called toss to determine the player to start the game. This module must receive two names of players. The module must randomly generate an integer 1 or 2, if 2 is generated the module must swap the received names of players, i.e. Player 1 must become Player 2 and Player 2 must become Player 1. A function called play that receives an option and return true if the player have won or false if the player have lost. If the received option is 1, this module must generate a random character from A to E and allow the user to guess that character at least three times. If the received option is 2, this function must generate a random integer from 1 to 5 and allow the user to guess the number at least three times. When the guess match the random display "Congratulations"message and return true, but if the guess was incorrect in three consecutive times, return false. Display the number of attempt left whenever the player is about to enter the guess. Main module (int main) display the heading "WELCOME TO THE GAME OF LUCK..! before prompting the user to enter two names of players. Call the toss function to determine the player to start. Player 1 must always be the one to start the game. Prompt player1 to select game option, either 1 to guess characters, or 2 to guess numbers. Call the play function to allow player 1 to guess and call play again to allow player 2 to guess. Use score 1 to count how many times player 1 has won and score 2 to count how many times player 2 has won. The programs must allow these two players to play until option 3 is entered. Show the overall winner of the game at the end of the program. Compile and run program. Figure 2.2.1 and 2.2.2 shows sample output. 4 DS017BT
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
