Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I was given the following sample code in order to create Java code that creates a book index from both user input and .txt file

I was given the following sample code in order to create Java code that creates a book index from both user input and .txt file input.

image text in transcribed

When ig.registerWord() is called, the current page should be associated with the word passed in. For this part, each page is 1 word long.

When operating on a .txt file, consider 500 words to be on 1 page, and any word used on more than 10 pages should NOT be included in the index.

I need an IndexGenerator with these classes:

registerWord(String s) //Registers word to index

setPage(int x) //Sets page number

printIndex(java.io.PrintStream out) //prints output of index

This should be done in a Map inside the IndexGenerator.

I also need the following classes: int wordCount() //return the number of different words in the index

String mostCommon() //return a word that appears on the most different pages

TIA!

public class TestDriver 1 public static void main(String [] args) Scanner input -new Scanner (System. in); IndexGenerator ig new IndexGenerator(); input.useDelimiter(" [a-zA-Z]+"); int page-0; for (int i-0; i

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

Question

For any n integer ( n > 0 ) what is the value for n / ( n + 1 ) = ?

Answered: 1 week ago