I need help with a word parsing project, and I don't know where to start

The instructions for this program given to me by my teacher are "Books-a-Trillion Publishing Company wishes you to write a program that will read a sentence on one line, one word at a time. The sentence is always terminated by either a ‘.’ , ‘!’, or ‘?’. The program will then output the number of words in the sentence, the average word length, and the length of the longest word. For simplicity, assume only the following punctuation marks are allowed within a sentence: ‘,’ and ‘;’ . A sample input would look like the following:

To be or not to be; that is the question!

The output should resemble the following:

There are 10 words in the sentence. The average length of each word is 3. The length of the longest word is 8 characters. " and he gave a pseudocode to help guide us which is

"//Prompt the user for a sentence terminated by a ‘.’, ‘!’ or ‘?’

//Read the first character

// Loop while the character that was read is not a ‘.’, ‘!’ or ‘?’

// increment word length

// if character is a blank, semicolon, or comma

// increment word counter

// resize the word length to exclude the blank, semicolon or comma

// check if the word length is the longest. If yes, save it

// reset word length to zero

// else

// increment character counter

// get the next character

//end of loop

// Output the results "

I just honestly have no idea where to start. Normally I don't ask a question like this for help with the whole code, but my family and I have had a very bad week and it's hard for me to keep focus right now and this code is very impactful on my grade.

Any and all help is greatly appreciated.

But what I have so far is:

#include <iostream>

#include <string>

using namespace std;

int main(int argc, char** argv) {
char ReadChar;
cout <<"Enter a sentence terminated by a period, an exclamation point, or a question mark (.!?) " << endl;

ReadChar = cin.get();
while ((ReadChar != '.') && (ReadChar != '!') && (ReadChar != '?'))

{
ReadChar = cin.get();

}

cout <<"Done reading" <<endl;



return 0;

}

I know this is just the skeleton and isn't very much, but I'm at a loss and I have no clue where to start
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/reference/cstring/strtok/?kw=strtok
Topic archived. No new replies allowed.