Question: Write a program that repeatedly reads in words ( or names ) without spaces until the string XXX is read. The program keeps track of

Write a program that repeatedly reads in words (or names) without spaces until the string XXX is read. The program keeps track of the smallest word that has been read so far (the one that would come first in alphabetical order) and outputs that word when XXX is encountered. It also outputs a count of the total number of non-whitespace characters in the input before the "XXXX".(Practice subsection Example: Finding the max value of section 4.1 Loops (general) and change it accordingly to fit your solution).
Ex: If the input is:
John Mary Andrew Stanley XXX
the output is:
Andrew 21 characters
A word is a sequence of characters with no spaces. Assume the words will either contain only lowercase letters or will all start with an uppercase letter followed by lowercase letters. Store the words in string variables and use < or > to compare the words (you do not need to look at individual characters). Assume there will be at least one word before XXX and all words will be unique.

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 Programming Questions!