Question: import java. util. Scanner; public class ProjectEliza { 12 public static void main(String args) { 13 14 Scanner scnr = new Scanner (System. in) ;

 import java. util. Scanner; public class ProjectEliza { 12 public staticvoid main(String args) { 13 14 Scanner scnr = new Scanner (System.

import java. util. Scanner; public class ProjectEliza { 12 public static void main(String args) { 13 14 Scanner scnr = new Scanner (System. in) ; 15 16 String name = ""; String sentence = ""; String yesOrNo = System. out. printIn("ELIZA: Hello, my name is Eliza. What is your name?"); System. out . printIn("USER: ") ; name = scnr . next( ) ; System. out. printf("ELIZA: Hello %s. Tell me what is on your mind today in 1 sentence. \ ", name); while( ! sentence. equalsIgnoreCase("EXIT") ) { System. out . printIn( "USER: "); sentence = scnr . next( ); sentence += scnr . nextLine(); if ( ! sentence . equalsIgnoreCase("EXIT") ) { String words = sentence . split("\\\\s+"); / /Splits sentence into an array without spaces if( sentence. charAt (sentence. length( ) - 1) == '?') { //Enter Questions_Bank System. out. printIn("ELIZA: " + PromptBank. getRandomQuestionTrunk(); * Cannot make a static reference to the non-static method getRandomQuestionTrunk() from the type PromptBank else if( sentence. charAt ( sentence. length( ) - 1) =='!') {//Respond with System. out . printIn("ELIZA: ") ; 2 quick fixes available: Change 'getRandomQuestion Trunk(' to 'static' else if( sentence. charAt (sentence . length( ) - 1) ==' . ') {//Respond with System. out . printIn("ELIZA: ") ; Create new instance of object 'PrintStream Press 'F2' for focus } //Outer IF Loop for Exiting dialogue System. out. printIn("ELIZA: Do you want to run the session again?"); System. out . printIn( "USER: "); yesOrNo = scnr . next( ) ; if(yesOrNo . equalsIgnoreCase("NO") ) { System. out . printIn("ELIZA: Goodbye, until next time"); break; else { } / /WHILE != "EXIT" Loop confirming exit }/ /MAIN }/ /CLASS80 import java util Scanner; ] 11 public class PromptBank { 12 13 14 String questions; 15 String statements; 16 170 public PromptBank( ) { 18 questions = new String[4]; 19 statements = new String[4]; 20 21 22 230 public void populateStatementsArray ( ) { 24 statements [0] = "Tell me more about BLANK1 and BLANK2"; 25 statements [1 ] : "BLANK1 seems important to you, so does BLANK2. Please tell me more."; 26 statements [2] = "BLANK1 and BLANK2 seem to be on your mind. Let's talk about it."; 27 statements [3] = "WOW! Dramatic! BLANK1 was unnecessary, and BLANK2 was just offensive."; 28 } 290 public void populateQuestionsArray ( ) { 30 questions[0] = "Is there anything else about BLANK1 and BLANK2?"; 31 questions [1] = "Does BLANK1 bother you? How about BLANK2?"; 32 questions[2] = "Are BLANK1 and BLANK2 things you think about often?"; 33 questions [3] = "I feel like BLANK1 is getting on your nerves. How about BLANK2?"; 34 35 36 public String getRandomStatementTrunk( ) { 37 Random random = new Random( ) ; 38 int randNums = random. nextInt(3); 39 40 String result = statements [ randNums ]; 41 42 System. out. printIn("ELIZA: " + randNums) ; 43 44 return result; 45 46 47 480 public String getRandomQuestionTrunk( ) {] 49 Random random = new Random( ) ; 50 int randNumQ = random. nextInt(4); 51 String result = questions [ randNumQ]; System. out . println("ELIZA: " + randNumQ) ; return result

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!