Question
Implement a class named FileParser, along with specified methods, that can read words from a text file, parse those words (such as finding palindromes), and
Implement a class named FileParser, along with specified methods, that can read words from a text file, parse those words (such as finding palindromes), and write those words to a new file.
More specifically: 1. Write the FileParser class so that it has the following methods:
a) public static void main(String[] args) -- The main driver of the program. Prompts the user for an input file, an output file, and a choice for what kinds of words to output.
b) public static String clean(String word)-- Takes a string and removes all non-letters, returning an all uppercase version. For example, this input: "A man, a plan, a canal. Panama." will produce this output: "AMANAPLANACANALPANAMA"
c) public static void parse(File in, File out)-- Parses an input file, writing each word from the input on a separate line in the output file.
d) public static boolean isPalindrome(String word) -- Determines if a word is a palindrome (reads the same forward and backward). The method is case-sensitive, so it will say that dad and DAD and d-a-d are palindromes.
e) public static void parsePalindrome(File in, File out) -- Parses an input file, writing only the palindromes to the output file, in alphabetical order, one line at a time, without repetition. Palindromes are words that read the same forward and backward, ignoring digits and punctuation.
f) public static int value(String word)-- Returns the monetary value of a word, found by assigning the value $1 to A, $2 B, and so on, up to $26 for Z. The method will ignore differences in case, so both A and a are each worth $1. It will also ignore any non-letters in the input.
g) public static void parseHundredDollarWord (File in, File out) -- Parses an input file, writing only the $100 words to the output file, in alphabetical order, one line at a time, in uppercase, without repetition. $100 words are found by assigning $1 to A, $2 to B, and so on. For example ELEPHANTS is a $100 word because: E + L + E + P + H + A + N + T + S is 5 + 12 + 5 + 16 + 8 + 1 + 14 + 20 + 19 = 100. You can use the value() method defined above to compute the value of a word.
2. Create your own input test file and use it with your code to generate three output files.
3. Upload all five files (Java source code, input file, three output files).
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