Solved–Lab 02 –Solution

$30.00 $19.00

PROGRAM SPECIFICATIONS Write a program to play “Guess my Number” In this game the computer picks a number between 1 and the range entered by the user and the player tries to guess it. The general flow of the game in this order is: The user is prompted for a number greater than 99 (You…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

PROGRAM SPECIFICATIONS

Write a program to play “Guess my Number”

In this game the computer picks a number between 1 and the range entered by the user and the player tries to guess it.

The general flow of the game in this order is:

  • The user is prompted for a number greater than 99 (You must ensure this)

  • The computer picks a random number between 1 and the number entered by the user.

  • The user is prompted for and enters their name

  • The game enters a loop that continues until the player guesses the correct number.

  • In that game loop the following things happen:

  1. The player guesses a number.

    • As long as the number is less than 1 or greater than the number the program loops and asks for a new guess.

  1. Once the player guesses a number in the right range the computer checks it.

  1. If the player’s guess is less than the computer’s number, the program prints “Too small” (or some

similar message).

  1. If the player’s guess is larger than the computer’s number, the program prints “Too large” (or some similar message).

    1. If the player guesses the computers number then the game loop should end.

  • Once the game loop ends the program should print “You guessed my number.” (or a similar message) and end.

  • The program will keep track of the number of player guesses and print this value at the end of the game. E.g. with a message like, “Good job, you guessed my number in only X guesses.” where X is the number of guesses the player took. Ultimately, the user is limited to 15 total guesses. This max guesses will be declared as a constant.

  • When a game is complete the player has the option to play again. This is simply a ‘y’ or a ‘n’. You must verify range of the character but you are guaranteed a single character.

NOTES

  • This is meant to be a simple conversion from a former Java program to C.

  • You will place all your code in main and I have provided cscd240Lab2.c and the main

  • You will NOT write functions for this lab.

  • I have provided a Makefile

TO TURN IN

A zip file of the Lab2 folder. The folder will contain:

  • Your/my C file with completed code

  • An output file named cscd240Lab2out.txt that contains at least 3 runs of your program.

  • My Makefile

Your zip will be named your last name first letter of first name lab2.zip (Example: steinerslab2.zip)