Reference no: EM133222
Question
Our program has to take a string representing a sentence in English and format it properly. The input sentence could have any or all of following errors-
Random letters can be capitalized.
The sentence could not end with a proper punctuation mark (period, question mark, or exclamation point).
There may be spaces at the beginning or end, or more than one space between words.
Format the sentence to fit following rules-
The first letter of first word should be capitalized.
The word "I" has to be capitalized.
All other letters in all words must be in lowercase.
The sentence should end with a punctuation mark. If original sentence did not end with a punctuation mark, add a period. (If an original sentence ended with more than one punctuation mark, it is not your responsibility to detect or fix this. yet, you should not cause this problem yourself by adding a period if sentence already ends with a punctuation mark.)
There have to be no spaces at the beginning or end of sentence.
There must be only a single space between words.