Question: Write a complete C++ program that does the following. and please include the comments to explain what you did. thankyou! Read a sentence from the

Write a complete C++ program that does the following. and please include the comments to explain what you did. thankyou!

 Write a complete C++ program that does the following. and please

Read a sentence from the console into a string, then parse it into separate words, using C++'s string find and substr functions The sample program sample line by line cpp will help with this portion ofthe assignment. C++'s input operator only reads up to the next whitespace (space, tab, newline and one or two other ascii codes). You can read an entire line at a time into one string variable using C++'s getline() function: string sentence; getline (cin sentence) will read everything up to the next newline (enter-key into the string variable sentence C++ strings have several useful functions built into the data type. sentence length will give you the length of the string; sentence. find ("fox") will find the first occurrence of the word "fox" in sentence. sentence find 10) will find the first space in sentence after the 10th character (ie, starting at sentence C10], which is the 11 character in the string). sentence substr (3,5) will extract a 5-character substring starting at the 4th char remember...C++ s 0-based!) sentence find returns the constant string: npos if the search doesn't find what you're looking for. 1) Write a program to read an entire sentence from the keyboard, then parse the sentence into individual words using find and substr Make sure your program gets the first and last words properly! You do not need to remove punctuation marks, but are welcome to do so for a little extra credit. Hint: google "C++ ispunct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!