Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Activity: Individual words from std::string to std::vector Graded Playground Autograder This is due on Monday, January 2 9 , 2 0 2 4 at 2

Activity: Individual words from std::string to std::vector
Graded Playground Autograder
This is due on Monday, January 29,2024 at 23:59 CST
You have not attempted this activity. You currently have 0% for this activity.
In this activity, you will implement std::vector WordsToVector(std::string str) in utilities.cc. This function must:
Takes a single std::string as its argument
Return a std::vector where each word (whitespace delimited) in the parameter str is an element, with all occurrences of the punctuation {!,?,.,,} removed from it.
Consider the following examples (std::string --> std::vector)
Hello, World! -->{"Hello", "World"}
What is your name? -->{"What","is", "your", "name"}
Who? What? Where? Why? How? -->{"Who", "What", "Where", "Why", "How"}
Do not include any libraries other than and in your solution.
Recommended process
Please do not overcomplicate this problem by attempting to use language facilities we have not taught. You can solve this problem using a combination of selection, iteration, and string concatenation. That's all you need!
Don't try to implement your solution to the whole problem at once! I recommend that you first create a function that removes the punctuation from an input string and returns a new string, containing all the original words, albeit with the punctuation removed. Before moving on, you can test your implementation driver.cc. Thereafter, you can define another function that returns an std::vector that "splits" on whitespace an input string into a vector of "words"; extracting the last word will likely be a special case. You can test your word-extracting function by invoking it from the main function and printing out the contents of the std::vector it returns using a for-statement. Finally, you can use these two functions to implement WordsToVector.

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions