Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

L03 Explain the mechanisms used to initiate and cease drinking.

Answered: 1 week ago