Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What you need to know to complete the project: Use the Scanner class to retrieve input from the user Manipulate Strings Work with Arrays Loops

What you need to know to complete the project:

Use the Scanner class to retrieve input from the user

Manipulate Strings

Work with Arrays

Loops for repetition

If-Else for logical decision branching

Using Classes and Methods

Program Details and Requirements:

*Use the starter code to create your PromptBank and modify it to work with your program.

*Your program should have 2 classes or more. 1 class is the starter code PromptBank, the other is your programs logic.

*The initial greeting should say Hello, my name is Eliza. What is your name?

*The user should enter their name.

*Then the program should greet the user by name and prompt them for input related to the therapy session

"Hello . Tell me what is on your mind today in 1 sentence.

*When the user submits their sentence your program should read in the line

*It should use the 1st word and last word from that line to form another prompt to the user by plugging those words into a statement or question randomly selected from the relevant array.

*Create methods that work with the starter code to replace BLANK1 and BLANK2 with the words from the line

*If the sentence the user enters ends with a ?, the program should prompt the user with a question built using the 1st word and last word of their line.

*If the sentence the user enters ends with a !, the program should prompt the user with a statement that starts with WOW! Dramatic! followed by the rest of the statement built using the 1st word and last word of their line.

*If the sentence the user enters ends with a . or any other character, the program should prompt the user with a statement built using the 1st word and last word of their line.

*This process should be repeated until the user types EXIT as a response

*When the user types EXIT the user should be asked if they want to run the session again.

*If they say yes, upper or lower case, run the program from the beginning

*If they say no, upper or lower case, say Goodbye, until next time

*Some of the things youll need to do to get the Project to work:

*Initialize your arrays to the appropriate length.

*Modify the existing methods in the starter code to populate the arrays by following the code comments

*Create methods to replace BLANK1 and BLANK2 in the sentence trunk you got from the array

Example:

ELIZA: Hello, my name is Eliza. What is your name?

USER: WonderWoman

ELIZA: Hello, WonderWoman. Tell me what is on your mind today in 1 sentence.

USER: Today is Friday.

ELIZA: Today seems important to you, so does Friday. Please tell me more.

USER: Friday is a fantastic day.

ELIZA: Friday and day seem to be on your mind. Let's talk about it.

USER: Why do want me to talk about Friday?

ELIZA: Does Why bother you? How about Friday?

USER: No!

ELIZA: WOW! Dramatic! No and No seem to be on your mind. Let's talk about it.

USER: I want to talk about the project.

ELIZA: I seems important to you, so does project. Please tell me more.

USER: EXIT

ELIZA: Do you want to run the session again?

USER: No

ELIZA: Goodbye, until next time

-----------------------

STARTER CODE:

public class PromptBank { String [] questions; String [] statements; public PromptBank(){ //questions = new String[ ]; //initialize your array to the correct length to match your number of questions you populate it with //statements = //initialize your array to the correct length to match your number of questions you populate it with } public void populateStatementsArray(){ questions[0] = "Tell me more about BLANK1 and BLANK2"; questions[1] = "BLANK1 seems important to you, so does BLANK2. Please tell me more."; questions[2] = "BLANK1 and BLANK2 seem to be on your mind. Let's talk about it."; /*complete this method with your other statements using BLANK1 for word1 * and BLANK2 for word2 place holder */ } public void populateQuestionsArray(){ questions[0] = "Is there anything else about BLANK1 and BLANK2?"; questions[1] = "Does BLANK1 bother you? How about BLANK2?"; questions[2] = "Are BLANK1 and BLANK2 things you think about often?"; /*complete this method with your other questions using BLANK1 for word1 * and BLANK2 for word2 place holder */ } /* public String getRandomStatementTrunk(){ //fill in the method so it randomly selects the statement template //from the questions array ... hint use Math.random() to get the random index //so you can replace BLANK1 and BLANK2 with the appropriate words } */ /* public String getRandomQuestionTrunk(){ //fill in the method so it randomly selects the question template //from the questions array ... hint use Math.random() to get the random index //so you can replace BLANK1 and BLANK2 with the appropriate words } */ } 

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago