Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you are to write a program that does the following: Prompt the user for an input file name which contains text. For

For this assignment, you are to write a program that does the following:

Prompt the user for an input file name which contains text. For our test case, you will be using the file provided by your instructor. You can find the input file in blackboard as an attachment to the assignment. It contains the lyrics for Tom Tom Clubs Wordy Rappinghood.

Read the file contents and parse it looking for words. For this assignment, you can consider a word bounded by white space. For instance, in the sentence: Words are fun, and sometimes they arent fun. The words are: Words, are, fun, and sometimes they arent fun. Note: you should treat words as case-insensitive. For example, "Words" would be the same as "words" or "WORDS" or "wOrDs", etc.

Use a class and instantiate objects to hold each unique word along with a count of that word as found in the input file. For instance, for the sentence in #2, Word is found once, are is found once, fun is found twice, Your program should ignore numeric data (e.g. 0, 1, ) as well as punctuation (things like . , ; : - )

Do NOT use a fixed size array to hold word strings or counts. Your program should work regardless of the size of the input file. My suggestion is to use an ArrayList of your word things (each object would have the words text along with a count of the number of times encountered). The ArrayList will allow you to dynamically generate the list of words. You should have appropriate getter and setter method on this class to get/set the word text as well as manipulate the word count. (Alternatively, you could have parallel ArrayLists, one for the word (String), and one for the count (Integer)).

After processing the file, you will generate an output report that contains, with one word per line: The word itself The number of times it appears in the input file

Your program must handle exception conditions properly using trycatch logic. For example, when you attempt to open the input file provided, you need to handle things like file not found conditions.

NOTE: wordy.txt contains the main test file (Tom Tom Club's song). But please also test your code with the other txt files.

Test txt file:

What are words worth? What are words worth? Words Words in papers, words in books Words on TV, words for crooks Words of comfort, words of peace Words to make the fighting cease Words to tell you what to do Words are working hard for you Eat your words but don't go hungry Words have always nearly hung me What are words worth? What are words worth? Words Words of nuance, words of skill And words of romance are a thrill Words are stupid, words are fun Words can put you on the run Mots pressez, mots sensez Mots qui disent la vit? Mots maudits, mots mentis Mots qui manquent le fruit d'sprit What are words worth? What are words worth? Words Its a rap race, with a fast pace Concrete words, abstract words Crazy words and lying words Hazy words and dying words Words of faith, tell me straight Rare words and swear words Good words and bad words What are words worth? What are words worth? Words What are words worth? What are words worth? Words Words can make you pay and pay Four-letter words I cannot say Panty, toilet, dirty devil Words are trouble, words are subtle Words of anger, words of hate Words over here, words out there In the air and everywhere Words of wisdom, words of strife Words that write the book I like Words won't find a right solution To the planet Earth's pollution Say the right word, make a million Words are like a certain person Who can't say what they mean Don't mean what they say A rap rap here and a rap rap there Here rap, there rap Everywhere a rap rap Rap it up for the common good Let us enlist the neighborhood It's okay, I've over stood This is a wordy rapping hood, okay, bye What are words worth? What are words worth? Words What are words worth? What are words worth? Words He don't stop He don't stop He don't stop Don't stop

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago