Question: 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
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 array of char).
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. Case does not matter: the user may guess a letter in either upper or lower case, the word is correct any case.
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) Please verify that you have completed each of these items
. 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. . Use a do while loop . Prompt the user to enter a letter or one of the symbols. . Inside the loop, use a switch statement to process the character entered. You may use the case range symbol. Use default for any invalid entries. . 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 appropriately.
Place 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.) 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 word it is sent and returns this count.
Here are the same function prototypes, using array notation.(If you use these, you can earn only 80 points total.) (//please don't use these) 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 data type). Do not write any additional functions.
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().
You will earn an additional 0 points if:
your code uses any array notation anywhere in the program
(Hint: search for [ . If you find it anywhere except to declare arrays in main(), it is array notation.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
