Follow the instructions for starting C++ and viewing the Advanced29.cpp file, which is contained in either the

Question:

Follow the instructions for starting C++ and viewing the Advanced29.cpp file, which is contained in either the Cpp8\Chap13\Advanced29 Project folder or the Cpp8\Chap13 folder. (Depending on your C++ development tool, you may need to open the project/solution file first.) If necessary, delete the two forward slashes that appear before the #include directive, and then save the program. The program assigns the letters of the alphabet to a string variable named letters. It also prompts the user to enter a letter. Complete the program by entering instructions to perform the tasks listed in Figure 13-35. Save and then run the program. Test the program appropriately.


Figure 13-35

1. Generate a random number that can be used to select one of the letters from the letters variable. Assign the letter to the randomLetter variable.

2. Verify that the user entered exactly one lowercase letter. If the user did not enter exactly one lowercase letter, display an appropriate error message.

3. If the user entered exactly one lowercase letter, compare the letter to the random letter. If the letter entered by the user is the same as the random letter, display the message “You guessed the correct letter.” and then end the program. Otherwise, display messages indicating whether the correct letter comes alphabetically before or after the letter entered by the user.

4. Allow the user to enter a letter until he or she guesses the random letter.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: