Question
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, youwill 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. To amuse yourself while coding, heres the actual song: https://www.youtube.com/watch?v=6Vl1m5FYlAo
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.
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.
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 try...catch logic. For
example, when you attempt to open the input file provided, you need to handle things like file not found conditions.
Please make sure you comment your code thoroughly. My preferred style is to not comment every line of code, but instead have a block comment for every logical section and to use line comments when you want to emphasize something special that line of code does.
The code should be nicely formatted and should use proper variables and variable names. While weve sometimes jokingly used wacko variable names in class, please do not do so in your assignment.
Bonus points:
a) 2 bonus points for programs that work with comments submitted by 2/26/2016
(early bird bonus).
b) 2 bonus point2 if you prompt the user for an output report file name and write the
report to this file with proper formatting.
Reminders:
Points are taken off for non-commented code! Each person needs to do their own work. Y
You get NO credit if your code doesnt compile. So, build your program slowly so that you can get partial credit in case you cant figure everything out.
Song Lyrics
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 presss, mots senss, mots qui disent la vrit, mots maudits, mots mentis, mots qui manquent le fruit d'esprit What are words worth? What are words worth? - words It's a rap race, with a fast pace Concrete words, abstract words Crazy words and lying words Hazy words and dying words Words of faith and tell me straight Rare words and swear words Good words and bad 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 no 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 With a rap rap here and a rap rap there Here a rap, there a rap Everywhere a rap rap Rap it up for the common good Let us enlist the neighbourhood It's okay, I've overstood This is a wordy rappinghood, okay, bye. What are words worth? What are words worth? - words What are words worth? What are words worth? - words He'll stop... Don't stop... Stop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started