Below is a C assignment, but if you just want a C online tutor then we can do that for you as well.
Hangman
Download the letterGame.exe file and letterList.txt file to play a few rounds of the game
- create a project and name the source code letterGame.c
- use the sample program1Outline as a guide, copy/ paste into your project source code
- copy/paste the function prototypes from the assignment into your source code and set up the function defintions
- set numGames to a small number (Just to test the connection to the file and the loop, later you will ask the user how many games)
- go to the assignment and save letterList.txt into the same directory as letterGame.c (remember to use your Z drive on portal.eng.fau.edu)
- declare a file pointer variable, connect to the input file and use fscanf to read the letters one by one from the file and print onto the screen (should read letters from the file)
- use printf statements to see the letters from the file print onto the screen
- write the function defintion and function call for rules function
- Get user input on how many games they wish to Play and update the numGames variable with user input (A function is not required here, but you may add a function)
- Write the function call to GuessTheLetter, passing the the solution letter from the file
- Again use printf statements inside the GuessTheLetter function to see that the letter was passed to the function and is lowercase
- write the function defintion and function call to the GetTheGuess function call the function from inside the while loop of the GuessTheLetter functionAgain use printf statements see the letter is lowercase
- write the function defintion and function call to the CompareLetters function, passing it both the guess and the solution use if/ else if/ else conditions to compare the letter and the guess and give feedback to the user, this function will return a 1 if the solution and guess match and a 0 if they do not match
- Add conditions in the GuessTheLetter function AFTER the END OF THE WHILE loop to test the variable win, if it is a 0 the user did not win, if it is a 1, the user won that round, let the user know if they won or lost.
Topics: printf, scanf, file input, user defined function, and conditions (if/else, switch) and loops
Synopsis: You will code a C program that is a letter guessing game. The user can pick
between 1-8 games to play. The program will read the letter from an input file for each game.
The user will try to guess the letter and has 1-8 tries to guess it correctly. After which, the
game ends and the next one begins.
Instructions:
- Write a program that reads letters from a file called "letterList.txt".
- Your program will ask the user to enter the number of games they wish to play (1 to 8)
- Your program will open the letterList.txt file read in one character at a time and repeat this for the number of games the user wants to play.
- For this assignment the test file will contain at least 8 letters, uppercase OR lowercase
- In your program you will change each letter (solution and guess) to lowercase
- Use the function tolower in #include
- When the number of games has been played, the program will end
- A sample of an input file that you can use to test your program is included with the assignment.
- A preprocessor directive must be used to define the maximum number of guesses as 5
- If the player has used up all of their guesses, a message that the game is over should be displayed along with the letter they were trying to guess.
- You must have at least 4 user defined functions as follows:
- No modifications may be made the to functions#define _CRT_SECURE_NO_WARNINGS#include#include#define MAXGUESSES 5//this function provides instructions to the user on how to play the gamevoid GameRules();//this function runs one game.//input: character from the file, void return type//all other functions to Play one round of a game//are called from within the GuessTheLetter functionvoid GuessTheLetter(char);//this function prompts the player to make a guess and returns that guess//this function is called from inside the GuessTheLetter( ) function described abovechar GetTheGuess();//this function takes two arguments, the guess from the player//and the solution letter from the file.//The function returns 1 if the guess matches the solution and returns a 0 if they do not match//This function also lets the user know if the guess comes alphabetically before or after the answerint CompareLetters(char, char);
Additional Requirements:
- Use function prototypes.
- Write comments for each function that will appear in the file before each prototype and again before each function definition.
- Be sure to comment your code adequately.
- Be sure to indent properly. Check your textbook and lecture code examples to see how it should be done.
- Use meaningful variable names
Sample Program Output:
Welcome to the Letter Guessing GameFirst, you will enter the number of games you want to play (1 - 8games)For each game you will have 5 chances to guess each letterLet's begin:How many games? (1 to 8) 2************************************Ready to play game 1----------------------------------------Getting guess number 1Enter a guess: wThe solution comes before your guess ( w )----------------------------------------Getting guess number 2Enter a guess: tThe solution comes before your guess ( t )----------------------------------------Getting guess number 3Enter a guess: SThe solution comes before your guess ( s )----------------------------------------Getting guess number 4Enter a guess: HThe solution comes before your guess ( h )----------------------------------------Getting guess number 5Enter a guess: fThe solution comes before your guess ( f )SORRY, you did not win this roundThe letter was dReady to play game 2----------------------------------------Getting guess number 1Enter a guess: aThe solution comes after your guess ( a )----------------------------------------Getting guess number 2Enter a guess: BThe solution and the guess are the same ( b )And you Won !!!Thank you for Playing the letter guess game
You should find a sample C assignment, that indicates the quality of the work we are able to do for you.
program1Outline.c
//add name , date, and description here#define _CRT_SECURE_NO_WARNINGS#include#define MAXGUESSES 5//paste all the function prototypes here//with the commentsint main(){//declare additional variables//declare FILE pointerint numGames, i = 0;char letter;//letter from file//display game rules//Ask and get number of games to play//connect to the file HINT: use fopen//this for loop will allow the player to play more than one game//without recompilingfor (i = 0; i < numGames; i++){//get a solution letter from file - use fscanf//change the solution to lowercase//print the solution back onto the screen to test//call the GuessTheLetter function and pass it the solution}//close file pointerreturn 0;}//this function runs one game.//input: character from the file, void return type//all other functions to Play one round of a game//are called from within the GuessTheLetter function//this function lets the user know if they have won or lost the gamevoid GuessTheLetter(char solution){int win = 0;int numGuesses = 0;//declare additional variableswhile (numGuesses < MAXGUESSES && win == 0){//get a guess from the user by calling the GetTheGuess function//change the guess to lowercase//win = call the function to compare the guess with the solutionnumGuesses++;//count the number of guesses so far}//use conditions to let the user know if they won or lost the round of the game}
Solution
For all your C project help that you need, you won't find a better place.
letterGame.c
//add name , date, and description here#define _CRT_SECURE_NO_WARNINGS#include#define MAXGUESSES 5//paste all the function prototypes here//with the comments/** Display Game Rule*/void GameRules();/** Function runs one game.* Input character from the file, void return type all other functions to play one round of a game are called within the GuessTheLetter function*/void GuessTheLetter(char);/** Function prompts the user to make a guess and returns that guess.*/char GetTheGuess();/** Function take two arguments, the guess from the player and the solution letter from the file.* Return 1 if the guess matches the solution* Return 0 if they not match.*/int CompareLetters(char, char);/** Print character in loop*/void printCharacter();int main(){//declare additional variables//declare FILE pointerint numGames, i = 0;FILE * input;char solution;char letter; //letter from filechar guess;//display game rulesGameRules();//Ask and get number of games to playprintf("\nHow many games? (1 to 8) ");scanf(" %d", &numGames);printCharacter('*');//connect to the file HINT: use fopeninput = fopen("letterList.txt", "r");//this for loop will allow the player to play more than one game//without recompilingfor (i = 0; i < numGames; i++){printf("\nReady to play game %d\n", i + 1);//get a solution letter from file - use fscanffscanf(input, "%c\n", &letter);//change the solution to lowercasesolution = tolower(letter);//print the solution back onto the screen to test//printf("\nThe letter is %c\n", solution);//call the GuessTheLetter function and pass it the solutionGuessTheLetter(solution);}//close file pointerfclose(input);printf("Thank you for Playing the letter guess game\n");//getchar();system("pause");return 0;}void GameRules(){printf("\nWelcome to the Letter Guessing Game.\n");printf("\nFirst, you will enter the number of fames you want to play (1 - 8)\n");printf("\nFor each game, you will have 5 chances to guess each letter\n");printf("\nLet's begin! \n");}//this function runs one game.//input: character from the file, void return type//all other functions to Play one round of a game//are called from within the GuessTheLetter function//this function lets the user know if they have won or lost the gamevoid GuessTheLetter(char solution){int win = 0;int numGuesses = 0;//declare additional variableschar guess;char letter;while (numGuesses < MAXGUESSES && win == 0){printCharacter('-');printf("Getting guess number %d\n", numGuesses + 1);//get a guess from the user by calling the GetTheGuess function//change the guess to lowercaseguess = GetTheGuess();//win = call the function to compare the guess with the solutionwin = CompareLetters(tolower(guess), solution);if (win == 0)printf("\nThe solution comes before your guess (%c)\n", tolower(guess));else{printf("The solution and the guess are the same (%c)\n", solution);printf("And you Won !!!\n");}numGuesses++; //count the number of guesses so far}//use conditions to let the user know if they won or lost the round of the gameif (numGuesses >= MAXGUESSES){printf("\nSORRY, you did not win this round\n");printf("The letter was %c", solution);}}//This function get a letter from userchar GetTheGuess(){char guess;printf("\nEnter a guess: ");scanf(" %c", &guess);return guess;}//This function compares the user letter with the letter from file.int CompareLetters(char guess, char solution){if (guess == solution){return 1;}else{return 0;}return 0;}//This function prints stars just because.void printCharacter(char character ){for (int i = 0; i < 30; i++){printf("%c ", character);}printf("\n");}
Here is an example C assignment, that demonstrates the sort of C project help we can deliver.
letterList.txt
d
B
G
w
Q
t
r
Y
u
X
Index:
- Hangman
- program1Outline.c
- letterGame.c
- letterList.txt
Don't rely on your friends to help you with your C assignment help as copying from them may lead to you both getting in trouble.