Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ output: Roses are Red. Violets are blue? Sugar is sweet. And so are you. Two roads diverged in a yellow wood, and Sorry I

c++
output:
Roses are Red. Violets are blue? Sugar is sweet. And so are you. Two roads diverged in a yellow wood, and Sorry I could not travel both, and be one traveler. Long I stood and looked down one as far as I could to where it bent in the undergrowth! Then took the other as just as fair, though having perhaps the better claim, for it was grassy and wanted wear. Though as for that the passing there had really worn them about the same. Both that morning equally lay, in leaves no step had trodden black. I saved the first for another day. Yet knowing how way leads on to way I doubted if I would ever come back. Some day ages and ages hence I shall be telling this with a sigh. Two roads diverged in a yellow wood, and I I took the one less traveled by. And that has made all the difference.
image text in transcribed
You are to write a program that will read a text file, echo it to the screen, and create an array of the words in the file. When the program terminates, it should produce a list of the words encountered and the number of times each word occurred (this information is to be stored in the array). The ordering of that list should be based on the order in which the words first occurred in the original text file with one word per line. Format the output line as: Word Count See Spot 4 Run 25 You may assume the following simplifying characteristics conceming the text file. The punctuation in the file consists only of periods, question marks, exclamation marks, and commas. There are 2 blanks following each period, exclamation mark, or question mark, followed by the first letter of the next sentence. The two blanks will be omitted if the delimiter terminates a line. There will be exactly one blank or the coln marker following each comma. Each line will terminate with '. An' will never be preceded by a blank. Paragraphs will be separated by a blank line, but will not be indented. Words that begin on a line in the text file will always end on that same line. Thus, no hyphenated words will occur. Your program should be case insensitive. Thus, the words Follow. FOLLOW, and follow would all be treated as the same word. When the word is stored in the list, save it as all lower case. Each word should be stored in the list only once, no matter how many times it occurs in the file. The list itself should be handled with an array of string[20]. That means you are to use c-strings, not string class objects in this program. You can assume that no word is longer than 19 letters. Recall that if you compare two strings of different lengths, the system will see them as two different strings. That is, a string(10) that contains Hello followed by 4 blanks, is not equivalent to a string(20) that contains Hello followed by 14 blanks. So (HINT), as you build a new word, blank out a string[20], and construct the word a letter at a time in the string[20]. You will know you have come to the end of a word when you encounter one of the word delimiters (period, comma, question mark, exclamation mark, and, of course, a blank space). Be sure to place the null terminator character ("\0) at the first unused space in the array to mark the end of the string. DUE DATE: Friday, March 5, 2021 at 10:00 PM (Submit on BlackBoard in Program 2 Turn-In Link). Turn In: Source Code (well documented) by the due date, and a copy of your output from the data file I will provide later. This file will be made available in the folder containing this program assignment on Blackboard by 8 PM on Monday, 3-1, 2021. Assume the data file will be called countem.txt. You will need to test the program extensively prior to seeing my data file. That is, test the program as you develop it with your own data files. You are to write a program that will read a text file, echo it to the screen, and create an array of the words in the file. When the program terminates, it should produce a list of the words encountered and the number of times each word occurred (this information is to be stored in the array). The ordering of that list should be based on the order in which the words first occurred in the original text file with one word per line. Format the output line as: Word Count See Spot 4 Run 25 You may assume the following simplifying characteristics conceming the text file. The punctuation in the file consists only of periods, question marks, exclamation marks, and commas. There are 2 blanks following each period, exclamation mark, or question mark, followed by the first letter of the next sentence. The two blanks will be omitted if the delimiter terminates a line. There will be exactly one blank or the coln marker following each comma. Each line will terminate with '. An' will never be preceded by a blank. Paragraphs will be separated by a blank line, but will not be indented. Words that begin on a line in the text file will always end on that same line. Thus, no hyphenated words will occur. Your program should be case insensitive. Thus, the words Follow. FOLLOW, and follow would all be treated as the same word. When the word is stored in the list, save it as all lower case. Each word should be stored in the list only once, no matter how many times it occurs in the file. The list itself should be handled with an array of string[20]. That means you are to use c-strings, not string class objects in this program. You can assume that no word is longer than 19 letters. Recall that if you compare two strings of different lengths, the system will see them as two different strings. That is, a string(10) that contains Hello followed by 4 blanks, is not equivalent to a string(20) that contains Hello followed by 14 blanks. So (HINT), as you build a new word, blank out a string[20], and construct the word a letter at a time in the string[20]. You will know you have come to the end of a word when you encounter one of the word delimiters (period, comma, question mark, exclamation mark, and, of course, a blank space). Be sure to place the null terminator character ("\0) at the first unused space in the array to mark the end of the string. DUE DATE: Friday, March 5, 2021 at 10:00 PM (Submit on BlackBoard in Program 2 Turn-In Link). Turn In: Source Code (well documented) by the due date, and a copy of your output from the data file I will provide later. This file will be made available in the folder containing this program assignment on Blackboard by 8 PM on Monday, 3-1, 2021. Assume the data file will be called countem.txt. You will need to test the program extensively prior to seeing my data file. That is, test the program as you develop it with your own data files

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_2

Step: 3

blur-text-image_3

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

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

Discuss the need to split data into test and training data.

Answered: 1 week ago

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago

Question

Briefly describe vegetative reproduction in plants.

Answered: 1 week ago