String representing a sentence in english


Your program should take a string representing a sentence in English and format it properly. The input sentence may have any or all of the following errors:

Random letters may be capitalized.
The sentence may 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 the following rules:
The first letter of the first word should be capitalized.
The word "I" should be capitalized.
All other letters in all words should be in lowercase.
The sentence should end with a punctuation mark. If the original sentence did not end with a punctuation mark, add a period. (If the original sentence ended with more than one punctuation mark, it is not your responsibility to detect or fix this. However, you should not cause this problem yourself by adding a period if the sentence already ends with a punctuation mark.)
There should be no spaces at the beginning or end of the sentence.
There should be only a single space between words.
Example:
java Sentence

corRect pUNCtuation is hard, i tHINk

RESULT: Correct punctuation is hard, I think.
Part 2

Create a method that does the same thing as your program, but takes its input from, and provides its output to, a calling program (do not use the IO module to interact with a human user). Define appropriate arguments (inputs) and return type, and implement this method. Test your method by calling it from another program.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: String representing a sentence in english
Reference No:- TGS080266

Expected delivery within 24 Hours