Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java code, I need to create this program. Miscellaneous String Operations Write a class with the following static methods: WordCount : This method should

In java code, I need to create this program.

Miscellaneous String Operations

Write a class with the following static methods:

WordCount: This method should accept a reference to a String object as an argument and return the number of words contained in the object.

arrayToString: This method accepts a char array as an argument and converts it to a string object. The method should return a reference to the String object.

mostFrequent: This method accepts a reference to a String object as an argument and returns the character that occurs the most frequently in the object.

replaceSubstring: This method accepts three references to String objects as arguments. Let's call them string1, string2, and string3. It searches string1 for all occurrences of string2. When it finds an occurrence of string2, it replaces it with string3. For example, suppose the three arguments have the following values:

string1: "the dog jumped over the fence"

string2: "the"

string3: "that"

With these three arguments, the method would return a reference to a String object with the value "that dog jumped over that fence".

Demonstrate each of these methods in a computer program.

Sample Output:

Number of words in "the dog jumped over the fence" is 6 Most frequently occuring character: e that dog jumped over that fence How now brown cow Press any key to continue . . .

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

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions