Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Look at the second picture first. The second picture is the main program where you've to make some correction. Open the program with the editor
Look at the second picture first. The second picture is the main program where you've to make some correction.
Open the program with the editor of your choice and observe the following:
Two statements from the JOptionPane class take care of the input and output of Strings. JOptionPane.showInputDialog(null, String) opens an input window containing the message in the String parameter. The user may enter any String, and click OK. The method returns the String. JOptionPane.showMessageDialog(null, String) simply displays the String asa message in a window and waits for the user to click OK. Compile and run the program 2. Note that no matter what word you type into the input dialog, the program always answers that the word is not on the list, because the method wordIsThere simply returns false Rewrite the method wordIsThere so that it searches the array for the given word and returns true only if the word is on the list. Remember that you cannot compare Strings with the "-=" operator. You must use the equals method of class String, for example: if (s1.equals (s2)) will compare String s1 with String s2 Compile and run the program 3. The program only words for one word at a time. Insert an if statement that will cause the program to terminate (call System.exit(O)) if the word entered is "STOP". Surround the code that does the input, search and output with an infinite while loop (while(true)code)). Compile and run the program. Two statements from the JOptionPane class take care of the input and output of Strings. JOptionPane.showInputDialog(null, String) opens an input window containing the message in the String parameter. The user may enter any String, and click OK. The method returns the String. JOptionPane.showMessageDialog(null, String) simply displays the String asa message in a window and waits for the user to click OK. Compile and run the program 2. Note that no matter what word you type into the input dialog, the program always answers that the word is not on the list, because the method wordIsThere simply returns false Rewrite the method wordIsThere so that it searches the array for the given word and returns true only if the word is on the list. Remember that you cannot compare Strings with the "-=" operator. You must use the equals method of class String, for example: if (s1.equals (s2)) will compare String s1 with String s2 Compile and run the program 3. The program only words for one word at a time. Insert an if statement that will cause the program to terminate (call System.exit(O)) if the word entered is "STOP". Surround the code that does the input, search and output with an infinite while loop (while(true)code)). Compile and run the program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started