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 applet based on this idea. The applet 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: “Te
```
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.
This programming project should be moved to Chapter 8 since event handling is not discussed at this point in the text, so processing button clicks hasn’t been covered.
This project looks at a tiny piece of computing history and can be used to introduce questions of artificial intelligence. The actual implementation of our application is pretty simple. Extending this applet to do a more complicated parsing of the input would be interesting. It would probably be a good idea as the action becomes more complicated move the parsing code out of setOnAction into its own dedicated method or methods.
See the code in Eliza.java.
You might also like to view...
What is meant by each of the following?
1. HTML 2. XML 3. XHTML 4. Map 5. Set 6. List 7. Relational Database 8. Helper Method 9. Database Driver 10. Connection 11. SQL 12. ODBC
Case AC 6-2Ross is exporting Access data into Word.What should Ross do to get the export of the Access database into Microsoft Word started?
A. Click the Export Data tab on the Ribbon, and then click the Word button in the Format group B. Click the External Data tab on the Ribbon, click the More button in the Export group, and then click Word. C. Click the Internal Data tab on the Ribbon, and then click the Word button in the Export group D. None of the above
The result of a ________ function depends on whether a condition is true or false
A) Statistical B) Text C) Logical D) Financial
Why is binary arithmetic employed by digital computers?
What will be an ideal response?