Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 split() String method. 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 lowercase like "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.

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

Students also viewed these Databases questions