get
and
getline
. The first part of the code will test each character
entered and print a message about the results. The second part will read
in a phrase and echo it to the screen.
Note that get
will wait until the enter key is pressed before it
returns a value, so you will need to clear the input stream before trying to
read the phrase with getline
.
Pseudocode for main:
print "Enter a list of characters (end with the character 'n'): " to the screen do get a character if it is a digit print "Found digit <value>" to the screen if it is a letter if it is a lowercase letter convert it to an uppercase letter print "Found letter <value>" to the screen if it is a punctuation character print "Found punctuation <value>" to the screen while value is not 'N' print "Enter a phrase: " read in the phrase print the phrase to the screen
Example output (user input is in blue):
Enter a list of characters (end with the character 'n'): u Found letter U L Found letter L 7 Found digit 7 . Found punctuation . n Found letter N Enter a phrase: Hello world! You entered: Hello world!
Name your code lab6.cpp. Email me the completed source code.