Explore BrainMass
Share

Explore BrainMass

    Simulating a Guessing Game, Two Players Against the Computer

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Guess My Number (High-Low) Two Players Take Their Turn

    Create a program that will simulate the child's number guessing game with two players who will play against the computer. The program should have the following requirements:

    1. When the program is invoked the computer will pseudorandomly choose which player will go first.

    2. Play begins when the computer interface asks "Player Number". A player number (either 1 or 2) is entered from the keyboard. If a player enters their number at the keyboard and it is not their turn the computer will report back "You have to wait your turn" and return to the query "Player Number". If it is a player's turn the computer will query "Enter Your Guess". The player may either enter a guess or indicate a desire to pass the play to the other player by entering the word PASS at the prompt. If the player enters a guess the computer will report back that the guess is too high, too low or correct and return to the query "Player Number" and pass play to the other player.

    3. No player may pass two turns in a row, and cannot exceed more than three passes for the entire game. If the player chooses to pass the computer should report "You have passed X number of times, you have Y more times left" before returning the query "Player Number".

    4. The play progresses until one user provides a correct guess.

    5. The program must be written in C and must be able to be compiled a.

    6. A professional quality pseudocode document must be provided.

    7. The source for the C program must be commented using best professional effort and should contain elements of the pseudocode as comments.

    © BrainMass Inc. brainmass.com October 10, 2019, 8:31 am ad1c9bdddf
    https://brainmass.com/computer-science/c/simulating-guessing-game-two-players-against-computer-632199

    Solution Preview

    Initialize player turn (t) as integer, player number (pNumber) as integer, user input (input) as string, pass count, currentPlayer as integer, and numberToGuess as integer

    Generate random number between 0-100 and assin it to numberToGuess

    Display "LET THE GAME ...

    Solution Summary

    The attached solution provides a well written easy to understand pseudocode, a working code in c, attached visual studio solution files, and a screen shot of the output. The code is well commented. Highly recommended for beginners to learn from.

    $2.19