Question: I need to write this program in c++ . please help me . Write a word guessing program. The user will try to guess a

I need to write this program in c++ . please help me .

Write a word guessing program. The user will try to guess a secret word by guessing letters and words. Choose a secret word of at least 10 characters and at least 2 duplicate letters. Initialize a character array to this secret word (it will be a c-string -- a null terminated string).

Every time the user guesses a letter, display how many times that letter occurs in the secret word. Each unique guessed letter should be stored in an array for future display. Tell the user if a letter has already been guessed. If so, don't store it more than once in the guessed letter array.

If the user types one of these symbols as the letter, do the following:

? allow the user to guess the word (if word is correct, exit the loop, if incorrect, continue asking for letters)

* display all letters that have been guessed up until that point, continue asking for letters

# quit display the secret word and exit the loop, do not continue asking for letters

main( ): Contains cout and cin. (30 points)

Display instructions to the user. Include what the special symbols will do.

Keep counters in main() of the number of unique letters guessed and the number of words guessed.

Declare an array to store the unique letters guessed, in the order they are guessed. It should not contain duplicates.

Declare an array of characters for the secret word, which should be all uppercase. It should be a c-string.

Loop, prompting the user to enter a letter or one of the symbols..

Use a switch statement to process the character entered. You may use the case range symbol.

The only way the loop ends is if the user guesses the secret word or enters # to quit.

After the loop ends either way, before ending the program:

o display the number of unique letters guessed (don't count duplicate guesses) o display the actual unique letters guessed in the order they were guessed

o display the number of words guessed (do include the correct word, if guessed)

Implement all of the following functions exactly as specified here and call them. All functions must have function prototypes above main() and function definitions below main().

Use exactly these function prototypes:

void uppercaseWord (char *); Does not contain any cout or cin. (15 points)

This function uppercases each letter in the word that it is sent. (Hint: The word is a c-string. To end the loop, look for the null terminator. Dont hard code or use the number of elements in the array.) (Hint: use the function toUpper( ) on each character. You dont need any library for this.)

bool compareWords (char *, char *); Does not contain any cout or cin. (20 points) :

This function compares two c-string words. It calls uppercaseWord() on each string before it compares them. It returns true if they match, false if they dont. To end the loop, look for the null terminator. Dont use coded length of a string. If the words are different lengths, this should return false.

int thisMany(char, char *); Does not contain any cout or cin. (15 points) This function counts how many times the specified character exists in the c-string word it is sent and returns this count.

Here are the same function prototypes, but using array notation.(If you use these, you can earn only 80 points total.) void uppercaseWord (char [ ]); bool compareWords (char [ ], char [ ]); int thisMany(char, char [ ]);

NO GLOBAL VARIABLES, ARRAYS OR CONSTANTS ALLOWED. Use only the iostream library (no other libraries allowed, don't use the string datat type). You may write additional functions, but you don't need to.

You may earn an additional 20 points only if:

your code matches the specification and runs correctly

your code uses only incremented pointers for all access to array elements throughout your code (i.e. *gPtr++) your code does not use pointers with offsets anywhere, i.e. *(gptr+i), except once, in main() when adding the guessed letter to the guessed letter array.

your code does not use array notation anywhere. This means that it does not contain [ ] brackets anywhere except to declare the arrays in main().

You may earn an additional 10 points only if:

your code matches the specification and runs correctly

your code uses only pointers with offsets for all access to array elements throughout your code i.e. *(gptr+i). your code does not use array notation anywhere. This means that it does not contain [ ] brackets anywhere except to declare the arrays in main().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!