Question
C++ Goals Problem solving and debugging. Function decomposition. C++ strings. Documentation of program. A text file contains a series of words that are to be
C++ Goals
Problem solving and debugging.
Function decomposition.
C++ strings.
Documentation of program.
A text file contains a series of "words" that are to be reformatted.
Design a C++ program that when given the file (via Linux redirection) will do the following
count the number of non-whitespace characters found in the file (before words are reformatted)
count the number of vowels (upper and lower case) found in the file
count the number of letters (upper and lower case) found in the file
count the number of digits found in the file
for each "word" read,
convert all letters to lower case
remove any leading characters that are not letters or digits
remove any trailing characters that are not letters or digits
display the formatted words (to the screen) in 4 columns (left justified)
determine the longest words in the file (before the leading/trailing characters have been removed and after)
compute the average length of the formatted words (after the leading/trailing characters have been removed)
display the counts, the longest words, and the average length of the formatted words with labels (do not set precision for average, leave at least one blank line between end of table and start of counts)
REQUIREMENTS
The program MUST make use of functions to solve the problem. Identify subtasks and use functions to implement them. Minimum of 3 meaningful functions (in addition to main).
Arrays and/or vectors and/or structs and/or classes CANNOT be used in this program.
DO NOT use global variables. DO NOT use goto statements.
Assumptions/Definitions
a "word" is any series of consecutive non-whitespace characters
sample words before reformatting: world, (2008) %#we're non-whitespace !!!
each word in the file will contain at least one letter or one digit
after the word is reformatted it must start and end with a letter or digit sample reformatted words: world 2008 we're non-whitespace r2d2
the "words" in the file will be separated by at least one blank space
each line in the file, including the last line of the file, will be terminated by a linefeed
the following letters will be considered vowels: A, E, I, O, U, a, e, i, o, u
maximum length of a word to be displayed will be 15 characters
the longest words in the file (both before and after formatting) will be unique
the input file will not be empty
Test your program adequately! Documentation When the program compiles and runs correctly, add the following documentation (comments) to your source file (.cpp file).
When a named constant and/or major variable is declared, provide a meaningful description of what it represents in the program.
For each function, clearly state what will be passed into the function and what will be passed out or returned by the function. Document important local variables. (See function documentation handout.)
Sample terminal session: Start of the code: #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started