Remember that to obtain pseudo random functionality, use the directive "#include ".
They are called pseudo random numbers for a reason; if when testing out your code the "random" numbers seem predictable, that is a natural side effect and it is recommended that you leave that alone.
Write code that implements a game with the following features:
-The game simulates the presence of two players, whose scores are both initially zero.
-The game starts by generating a random number in the range 20 to 63, and outputs that many asterisks "*" to screen using aforloop. Asterisks should be displayed with at least one space between each one, and there should also be a new line every 8 characters.
-Display the answer as well, so that it is easier for us to test the code.
-The game asks player1 to enter a guess of how many asterisks there are on screen.
-The game then asks player2 the same question. You may assume that all input entered is correct.
-If both players guess it wrong or both guess it right, no one wins that round.
-If only 1 of the players guessed correctly, that player wins the round.
-The game is played until one of the players reaches a score of 2.
- The game should automatically loop back and start all over again once the game ends. In this case it will result in an infinite loop, but that is fine for this lab.
Try playing this game when you think you are done to make sure that the rules are being followed.
Sample Output: If the random numbers generated for each round were 27, 32, 21, 55, 20, 29 it might play out like this:
Note:While it is definitely true that your randomness will not end up like this, you should be testing your game with the same ideas represented in each round. For example, in the first round below, you should mimic the output by having the first player guess correctly and the second player incorrectly, and make sure that player1 wins the round. In the second round, make sure that both players enter the same correct answer, and that no one wins as a result, so on and so forth.
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * *
The answer is 27.
0 to 0
Player 1 enter a guess: 27
Player 2 enter a guess: 23
Player 1 wins the round!
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
The answer is 32.
1 to 0
Player 1 enter a guess: 32
Player 2 enter a guess: 32
No one wins!
* * * * * * * *
* * * * * * * *
* * * * *
The answer is 21.
1 to 0
Player 1 enter a guess: 25
Player 2 enter a guess: 21
Player 2 wins the round!
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * *
The answer is 55.
1 to 1
Player 1 enter a guess: 27
Player 2 enter a guess: 28
No one wins!
* * * * * * * *
* * * * * * * *
* * * *
The answer is 20.
1 to 1
Player 1 enter a guess: 20
Player 2 enter a guess: 34
Player 1 wins the round!
Player 1 wins the game!
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * *
The answer is 29.
0 to 0
Player 1 enter a guess:
Player 2 enter a guess:
(The game continues forever)