ELIZA was a program written in 1966 that parodied a psychotherapist session. The user typed sentences and
Question:
ELIZA was a program written in 1966 that parodied a psychotherapist session. The user typed sentences and the program used those words to compose a question.
Create a simple GUI application based on this idea. The program will use a label to hold the program’s question, a text field into which the user can type an answer, a button for the user to signal that the answer is complete, and a quit button.
The initial text for the question label should read: “What would you like to talk about?” When the user presses a button, get the text from the text field. Now extract the words from the text one at a time and find the largest word of length 4 or more. Let’s call this largest word X for now. In response, create a question based on the length of the word. If the word is length 4, the new question is: “Tell me more about X.” If the word is length 5, the new question is: “Why do you think X is important?” If the word is length 6 or more, the new question is: “Now we are getting somewhere. How does X affect you the most?” If there is no word of length 4, the new question is: “Maybe we should move on. Is there something else you would like to talk about?” (Hint: You can use the class Scanner to extract the words from a string, assuming blanks separate the words. For example, the following statements
String text = " one potato two potato ";
Scanner parser = new Scanner(text);
System.out.println(parser.next());
System.out.println(parser.next());
display one and potato on separate lines.)
Step by Step Answer:
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch