Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

According to the following C++ code from Visual Studio, rewrite it with more function with the request in the image. #include #include #include //library includes

According to the following C++ code from Visual Studio, rewrite it with more function with the request in the image.

#include #include #include//library includes the definition of rand funcion (a random number generator) and the exit function #include//library includes the the definition of time funcion. using namespace std; int main() { int NUMBER_OF_GUESSES = 5; int numberOfGames = 0; int loopCounter; char usersGuess, secretLetter; bool winFlag = false; //ifstream inputFile; //Uncomment for option two read the value from the file /* //Uncomment for option two read the value from the file inputFile.open("Secret_Letters.txt"); //Uncomment for option two read the value from the file if (inputFile.fail()) //Uncomment for option two read the value from the file cout4) { cout > numberOfGames; } for (int i = 1; i >secretLetter; //Uncomment for option two read the value from the file //cout> usersGuess; if (usersGuess == secretLetter) { winFlag = true; break; } else if (usersGuess>secretLetter) { cout

image text in transcribed

Guessing game program using functions General Requirements for project 2 Rewrite the program from project 1 using at least four user-defined functions other than the main function All functions (except the main function) will be defined as follows The function prototype appears before the main o o o Comment describing what the function does appears directly under function prototype Formal variable names are not used in any prototype The functions definition appears after the main The first function's name is introduction, which will print (show on the screen) * Welcome to the Letter Guessing Game You will enter the number of games you want to play (1- 4 games) You have 5 chances to guess each letter Let's begin The second function's name is getNumberOfGame, which asks the user about the number of games to be played and returns the value. This function will validate the user input to make sure it is in the desired range (1-4) inclusive, if the value is out of range the user is notified and asked again . How many games do you want to play (1-4)3 The third function's name is compareTwoCharacters, which receives two parameters of type character (e.g. the character to be guessed in that game and the character typed by the user). This functions return 0 if the two characters are the same, returns 2 if the first parameter comes after the second parameter, otherwise it returns -2 The fourth function's name is playOneGame, which receives one parameter of type character (the character to be guessed in that game). This function returns true if the user won; otherwise will return false. This function will handle all tasks to play one game (ask the user to enter their guess, provide up to 5 chances to guess, provide a hint to the user, etc.). This function is going to call the third function (i.e. compareTwoCharacters) to decide if the user has guessed the correct answer or to provide a hint to the user * Make sure to follow the instructions carefully including using the exact function names with the exact letter cases (upper and lower case letters). Your programs are going to be tested using a unified main function that is developed for that purpose. If the unified main function does not compile this indicates inconsistencies in meeting the above requirements and will result in a zero grade. *

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the main sources of conflict between functions?

Answered: 1 week ago

Question

37.05 + (-19.26) Find the sum by hand.

Answered: 1 week ago