Question: In the starter code, a file named Debug. java is given. The class Debug has a main method. This method has to take a String

 In the starter code, a file named Debug. java is given.The class Debug has a main method. This method has to take

In the starter code, a file named Debug. java is given. The class Debug has a main method. This method has to take a String array as its parameter from the command line, consider the initial argument of the array as a keyword, and print the number of occurrences that the keyword appears in the rest of the array. The code has several runtime errors. Fix the errors so that the code satisfies the following: 1. If the input array is empty, then the output should print No keyword is given 2. If the input array is not empty, the initial argument should be a keyword with the prefix - - (two dashes). If the argument does not satisfy this format, then the output should print Write a keyword with the prefix -- 3. If the input array is not empty and the keyword is given in the correct format, then calculate the count of occurrences of the keyword after the initial argument. If the array has only one String, then the count is 0 . The output should print The answer is [count] Examples: \$ javac Debug.java $ java Debug No keyword is given $ java Debug melon Write a keyword with the prefix -- $ java Debug --melon The answer is 0 $ java Debug --melon apple orange melon watermelon melon banana The answer is 2

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 Databases Questions!