Consult the countwordsjava program provided below you will


Need help with a Java problem:

Write a program called SearchText.java that:

Prompts the user for a text file pathname.

Prompts the user for a search string.

Reads in all of the text in the file.

Splits that text into an array of words.

Prints a list of every word that contains the search string.

After that list, prints a count of how many words contain that search string.

For example, running this program for the file constitution.txt and using the search string qu produces the output:

Tranquility requisite subsequent Consequence equally equally disqualification require question questioned question Marque square require Consequence Marque equal equal quorum equal require Equity Consequence equal required quartered required equity quorum quorum equal questioned qualifications requisite liquors qualify qualified qualified qualified liquors equal required Number of words containing "qu": 42

As a model, consult the CountWords.java program provided below. You will have to look up the method in the String class that indicates whether one string contains another.

CountWords.java:

import stdlib.*;

public class CountWords {

public static void main(String[] args) {
StdOut.print("Please enter the pathname or URL of the book file: ");
String textSource = StdIn.readLine();
StdIn.fromFile(textSource);
final String bookText = StdIn.readAll();
String[] bookWords = bookText.split("\\s+");
StdOut.println ("There are " + bookWords.length + " words in " + textSource + ".");
}

}

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Consult the countwordsjava program provided below you will
Reference No:- TGS02869541

Expected delivery within 24 Hours