Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: image text in transcribed Start of the code: #include #include using namespace std; //first function //second function //third function int main() { cin >> data; while (cin) { } cin >> data; return 0; }

Sample terminal session: eys] S more data. 4three This is a test of the program. let's see what haPPens r2D2 23 skidoo WHEN some data is proces seda 33 Good-bye THE END! keys] s g assign 03 cpp keys S a., out data 4three Word List the program what happens when data processed good-bye the Non-whitespace characters: 113 vowels: 31 Letters: 85 Digits: 4 Longest word before formatting program Longest word after formatting r2d2 23 skidoo Average length of formatted words 4.6 test. let's r2d2 23 skidoo end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

How is E-business a more broad concept than e-commerce?

Answered: 1 week ago