Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Exercise 08.1 Searchable Text File USE JAVA The purpose of this program is to create a class named Searcher that inherits the necessary functionality

Lab Exercise 08.1

Searchable Text File

USE JAVA

The purpose of this program is to create a class named Searcher that inherits the necessary functionality of a text file and adds functionality to search and count occurrences.

The search method will read a text file, read a string from the user, search the text file for all occurrences of the string and print the string along with the number of occurrences found.

The class will:

Inherit the File class

Use (as an attribute) the Scanner class

Receive the text file name in the class constructor (file will be longer than 1000 words)

The search method will:

Receive the search-string (16 characters or fewer)

Open the text file

Read the input file, searching for the search-string while reading (file will be longer than 1000 words)

Count occurrences of the text string

Close the text file

Print the search-string and the number of occurrences

Ex: xYz was found 11 times in data.txt

Remember to test thoroughly, including

No matches

One match

Many matches

The matching must be case-sensitive.

Remember that a text string can span two or more words.

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 Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago