Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

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

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

Step: 3

blur-text-image

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago