Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write this program using C + + Part 1: Word Frequency Problem Statement: You are tasked to write a program that will count the frequency
Write this program using C + +
Part 1: Word Frequency Problem Statement: You are tasked to write a program that will count the frequency of the given words in a particular sentence or a paragraph. The (or paragraph), then ask for N words that the user wants to search for in the sentence (or paragraph), and output the frequency for each. The sentence/paragraph must be a C-style string (array of characters ended by the null character, "l0"), but the array of words can be C++ strings program will first ask the user for a string input that is a sentence The N words must be entered at one time before searching to see if the words are in the sentence/paragraph. In other words, you cannot ask for a word, search its frequency and then ask for another word. You must ask for all words before searching for the words. You must use a dynamic array allocated on the heap!!! You will not be given credit for a variable length array, which is not dynamically allocated on the heap, i.e. string array [num_words]; In addition you must not have a memory leaks (use valgrind to help)! Note: Word frequency is case insensitive. E.g. "the" and "The" are the same (10 pts) Extra Credit: Use an array of C-style strings for the words, instead of C++ strings. You do not have to do both. Either make the words C-style strings for extra credit OR an array of C++ strings (80 pts) Implementation Requirements Must produce two working programs that follows each rule stated above Your user interface must provide clear instructions for the user and information about the data being presented Use of one-dimensional array/C-style strings is required .Use of references or pointers is required Your program should be properly decomposed into tasks and subtasks using functions To help you with this, use the following o Make each function do one thing and one thing only o No more than 15-20 lines inside the curly braces of any function, including main(). Whitespace, variable declarations, single curly braces, vertical spacing comments, and function headers do not count. o Functions over 20 lines need justification in comments o Do not put multiple statements into one line No global variables allowed (those declared outside of many or any other function) global constants are allowed goto is NOT allowed You must not have any memory leaks! Make sure you follow the style guidelines, have a program and function headers with appropriate comments, and be consistent . (10 pts) Extra Credit: Keep a journal of errors you run into using pointers in this assignment. You must record 1) whether the error was at compile time or runtime, 2) what the error was, 3) the line number it occurred on, 4) what you did to fix it, and 5) why this fixed it. Part 1: Word Frequency Problem Statement: You are tasked to write a program that will count the frequency of the given words in a particular sentence or a paragraph. The (or paragraph), then ask for N words that the user wants to search for in the sentence (or paragraph), and output the frequency for each. The sentence/paragraph must be a C-style string (array of characters ended by the null character, "l0"), but the array of words can be C++ strings program will first ask the user for a string input that is a sentence The N words must be entered at one time before searching to see if the words are in the sentence/paragraph. In other words, you cannot ask for a word, search its frequency and then ask for another word. You must ask for all words before searching for the words. You must use a dynamic array allocated on the heap!!! You will not be given credit for a variable length array, which is not dynamically allocated on the heap, i.e. string array [num_words]; In addition you must not have a memory leaks (use valgrind to help)! Note: Word frequency is case insensitive. E.g. "the" and "The" are the same (10 pts) Extra Credit: Use an array of C-style strings for the words, instead of C++ strings. You do not have to do both. Either make the words C-style strings for extra credit OR an array of C++ strings (80 pts) Implementation Requirements Must produce two working programs that follows each rule stated above Your user interface must provide clear instructions for the user and information about the data being presented Use of one-dimensional array/C-style strings is required .Use of references or pointers is required Your program should be properly decomposed into tasks and subtasks using functions To help you with this, use the following o Make each function do one thing and one thing only o No more than 15-20 lines inside the curly braces of any function, including main(). Whitespace, variable declarations, single curly braces, vertical spacing comments, and function headers do not count. o Functions over 20 lines need justification in comments o Do not put multiple statements into one line No global variables allowed (those declared outside of many or any other function) global constants are allowed goto is NOT allowed You must not have any memory leaks! Make sure you follow the style guidelines, have a program and function headers with appropriate comments, and be consistent . (10 pts) Extra Credit: Keep a journal of errors you run into using pointers in this assignment. You must record 1) whether the error was at compile time or runtime, 2) what the error was, 3) the line number it occurred on, 4) what you did to fix it, and 5) why this fixed itStep 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