Write a Java program that allows users to enter multiple sentences and revises t
ID: 3728910 • Letter: W
Question
Write a Java program that allows users to enter multiple sentences and revises the sentences by replacing certain negative words with more positive words. The users can enter multiple whitespaces between words, DO NOT alter their spacing if the users use multiple whitespaces. DO NOT use arrays, regEx, replaceAll() and import java.io.*. Go through character by character to locate each token. Write as many additional methods as it is needed to assist with the work.
Specification:
1. Four target words: 1) Replace "fake" with "ingenious" 2) Replace "ugly" with "gorgerous" 3) Replace "strange" with "extraordinary" 4) Replace "unintelligent" with "quick-witted"
2. Do not convert embedded words: If the users embeds the negative words in other words, like "faker", "stranger", "unintelligently", DO NOT convert the words.
3. Adjusts the "a" and "an" if they appear before a target word: If the users enter "He is a fake person. He is an ugly person. He is a strange person. He is an unintelligent person.", the sentences should be converted to "He is an ingenious person. He is a gorgeous person. He is an extraordinary person. He is a quick-witted person." DO NOT change the "a" and "an" if they do not appear before a target word.
4. If the user enter something strange like "aN ugLY person", convert the replacement words to lowercaselike "a gorgerous person" (Assume that the replacement word would never appear as the first word of a sentence)
SAMPLE RUN:
(User enters) He is so faKE!!! You cannot find a faker person. I think a fake person is annoying.
Revised text: He is so ingenious!!! You cannot find a faker person. I think an ingenious person is annoying.
(User enters) He is AN UGLY person. He is so UNINTELLIGENT. He behaves strangely.
Revised text: He is a gorgerous person. He is so quick-witted. He behaves strangely.
(User enters) He is An (if the user enters five whitespaces between "An" and "ugly") ugly person.
Revised text: He is a (keep the five whitespaces between "a" and "gorgerous") gorgerous person.
Explanation / Answer
OUTPUT:
(User enters): He is so faKE!!! You cannot find a faker person. I think a fake person is annoying.
He is so ingenious!!! You cannot find a faker person. I think an ingenious person is annoying.
Process finished with exit code 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.