Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read the entire document before starting to write code. Write and test a Java project that satisfies the following requirements: Searching for a string of

Read the entire document before starting to write code. Write and test a Java project that satisfies the following requirements: Searching for a string of characters in a body of text is a common application of computers. I am sure you recall using ctrl-f to find a specific word in a document. Ways to implement this problem has been of great interest in the study of computer science algorithms. In this assignment you are going to implement a brute-force approach to this problem. This is not an efficient solution, and after this test has been submitted, I will tell you another algorithm to solve this problem, which you can then implement and submit for more extra credit. Overview- find a word in a text file. Report how many times the word appears in the text file and on which lines.

More specifics: Your Java project will ask the user to enter the entire the path and name of a text file and ask the user for a word to search for. Your project will report on the screen how many times the word appears in the text and the line numbers where the word is found. For simplicity, case will NOT matter. That means if the user is searching for the word, answer, any hits on this word, such as Answer, answer, ANSWER count as a match. If you give the user the option of whether case matters, that will earn 10 points more extra credit points.

The Java API for the String class and the StringBuilder class have implemented this in some methods such as the indexOf( ) method. However, you are doing this exercise as a Computer Science exercise and you are not allowed to use these API methods. The only methods of the String or StringBuilder class you are allowed to use are the length( ) method the charAt( ) method, the toUpperCase( ) method and the toLowerCase( ) method. If you use the other methods you will earn a zero on this extra credit test. Write this project using the object-oriented paradigm.

The main( ) method will only prompt the user and read input, call the methods of the other class, and print the output to the screen. Rubric: The code must compile and run using BlueJ without modification. If your code does not compile and run using BlueJ, the grade will be a zero. The code must be well documented. Document each method and use the conventions for naming fields, constants, local variables, constants and class names. Use javadoc style comments above each method as well as inline comments. The code must have at least two classes, the Driver and another class that does all the searching.

The code must give correct results in the output. The code cannot use the methods of the String or StringBuilder classes except for the length( ) and charAt( ) and toUpperCase( ) and toLowerCase( ). If you submit anything other than the .java source code files, your grade will be a zero.

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

More Books

Students also viewed these Databases questions