For this assignment, you are to write a program that does the following: Prompt
ID: 3671858 • Letter: F
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 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 Club’s “Wordy Rappinghood”. To amuse yourself while coding, here’s 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 aren’t fun.”
The words are: “Words”, “are”, “fun”, “and” “sometimes” “they” “aren’t” “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 word’s 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 we’ve 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 doesn’t compile. So, build your program slowly so that you can get partial credit in case you can’t figure everything out.
Song Lyrics
Explanation / Answer
Please find the code below :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.