Question: The java program is a conversation. 1. If the user input contains the word because and there is something after because other than spaces or

The java program is a conversation.

1. If the user input contains the word "because" and there is something after "because" other than spaces or punctuation marks, respond with "Is "" the real reason?", where text is formed by:

1.a Start by taking what came after the user input following "because". For example, "Late because ...my car stalled!!" becomes " ...my car stalled!!".

1.b Strip off leading and trailing punctuation marks and spaces. For example, " ...my car stalled!!" becomes "my car stalled"

1.c Switching first and second person pronouns and possesives. For example, "my car stalled" becomes "your car stalled" ( In other cases, "your" switch to "my"; "I" switch to " you"; "you" switch " I "; "me" switch "you"; "you" switch to "me"; "mine" switch "yours"; "yours" switch "mine".

2. Otherwise, if the input contains an even number of words, respond with "Tell me more."

3. Else, respond with "Whatever."

4.If input is nothing(hitting enter) , output is "Bye for now"

Example dialogue:

Talk to me, or hit enter to quit: This is interesting

Whatever.

Talk to me, or hit enter to quit: This is so interesting

Tell me more.

Talk to me, or hit enter to quit: I always say that just because.

Tell me more.

Talk to me, or hit enter to quit: I always say that just because!

Tell me more.

Talk to me, or hit enter to quit: Because my life is short.

Is "your life is short" the real reason?

Talk to me, or hit enter to quit: Maybe not, sometimes I'm confused

Whatever.

Talk to me, or hit enter to quit: ???!!!

Whatever.

Talk to me, or hit enter to quit:

Bye for now

Could you help giving me on this? I am really stuck. Try not to use advanced java method. So far I just learn loops; substring; replace; charAt; contains and so on.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!