2. Using the algorithm developed above, create a function that determines the status of the first character of a word. The function should receive a string containing a single word as the first parameter which should be defined as constant, and integer reference parameters containing the counts for the number of vowels, consonants and numbers found in a sentence. The main function should open a file containing sentences, read each sentence, and use the function to add to the counts for each word of the sentence. The main function should output each sentence read from the file and the total counts for each sentence. Hints: Each sentence from the file must be parsed into individual words which the function can examine. You may assume words will be separated by a single space.The find and substr string methods can assist in the parsing of the sentence. Alternatively, you may use a stringstream object to parse each line read from the file. See Strings.cpp and StringStream.cpp examples. Please see http://www.cplusplus.com/reference/string/string/e to learn more about using the find and substr functions and http://www.cplusplus.com/reference/sstream/istringstream/str/ e to learn about the istringstream class. The text input can be created with any simple text editor such as NotePad. InjGrasp, text files can be created be selecting New | Plain Text from the File menu. Store the text file in the same folder as the program. Example run: Input string: There are 3 cats in the yard! 2 words begin with a vowel 4 words begin with a consonant 1 other 'words' were found Input string: Fall is a beautiful time of year. 3 words begin with a vowel 4 words begin with a consonant O other 'words' were found Input string: There are 12 inches in a foot. 4 words begin with a 2 words begin with a consonant 1 other 'words' were found vowel

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 21SA
icon
Related questions
Question
100%

Please use easy logic with proper indentations and comments for understanding!. Coding should be in C++. I am providing an algorithm that you will need to answer this coding question. I am also providing this solved program but it's not printing each line separately as it supposed to (Output given). The file has 3 separate lines. Our program supposed to print three separate lines as exactly shown in the sample output. Please review my code and provide a correction to it. Thank you

 

2. Using the algorithm developed above, create a function that determines the status of the first character of a
word. The function should receive a string containing a single word as the first parameter which should be
defined as constant, and integer reference parameters containing the counts for the number of vowels,
consonants and numbers found in a sentence. The main function should open a file containing sentences, read
each sentence, and use the function to add to the counts for each word of the sentence. The main function
should output each sentence read from the file and the total counts for each sentence.
Hints: Each sentence from the file must be parsed into individual words which the function can examine. You may
assume words will be separated by a single space.The find and substr string methods can assist in the parsing of
the sentence. Alternatively, you may use a stringstream object to parse each line read from the file. See
Strings.cpp and StringStream.cpp examples. Please see http://www.cplusplus.com/reference/string/string/e to
learn more about using the find and substr functions
and http://www.cplusplus.com/reference/sstream/istringstream/str/ e to learn about the istringstream class.
The text input can be created with any simple text editor such as NotePad. InjGrasp, text files can be created be
selecting New | Plain Text from the File menu. Store the text file in the same folder as the program.
Example run:
Input string: There are 3 cats in the yard!
2 words begin with a vowel
4 words begin with a consonant
1 other 'words' were found
Input string: Fall is a beautiful time of year.
3 words begin with a vowel
4 words begin with a consonant
O other 'words' were found
Input string: There are 12 inches in a foot.
4 words begin with a
2 words begin with a consonant
1 other 'words' were found
vowel
Transcribed Image Text:2. Using the algorithm developed above, create a function that determines the status of the first character of a word. The function should receive a string containing a single word as the first parameter which should be defined as constant, and integer reference parameters containing the counts for the number of vowels, consonants and numbers found in a sentence. The main function should open a file containing sentences, read each sentence, and use the function to add to the counts for each word of the sentence. The main function should output each sentence read from the file and the total counts for each sentence. Hints: Each sentence from the file must be parsed into individual words which the function can examine. You may assume words will be separated by a single space.The find and substr string methods can assist in the parsing of the sentence. Alternatively, you may use a stringstream object to parse each line read from the file. See Strings.cpp and StringStream.cpp examples. Please see http://www.cplusplus.com/reference/string/string/e to learn more about using the find and substr functions and http://www.cplusplus.com/reference/sstream/istringstream/str/ e to learn about the istringstream class. The text input can be created with any simple text editor such as NotePad. InjGrasp, text files can be created be selecting New | Plain Text from the File menu. Store the text file in the same folder as the program. Example run: Input string: There are 3 cats in the yard! 2 words begin with a vowel 4 words begin with a consonant 1 other 'words' were found Input string: Fall is a beautiful time of year. 3 words begin with a vowel 4 words begin with a consonant O other 'words' were found Input string: There are 12 inches in a foot. 4 words begin with a 2 words begin with a consonant 1 other 'words' were found vowel
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Algebraic Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning