Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA e is a sequence of characters that is the same when read forwards and backwards. The following are all palindromes: o Anna o live
JAVA
e is a sequence of characters that is the same when read forwards and backwards. The following are all palindromes: o Anna o live devil Able was I, ere I saw Elba.1 e Notice that we consider only the letters-ignoring case, punctuation, and whitespace when we look for palindromes We can recursively test a String s to see if it is a palindrome using the foll algorithm o Calculate the length of the string If the s has length 0 or length 1, then s is a palindrome. This is the base case If the first and last letters of the s are the same, then form a substring of s consisting of the letters in position 1 to length - 2. If this substring is a palindrome, then s is a palindrome. This is the recursive definition Otherwise, s is not a palindrome o e In this project, we are going to write a program that reads lines from a text file and determines if each line is a palindrome You should create your program in two parts. In the first part, write a class called Strippedstring that stores a String and a "stripped" version of the String The stripped version contains only the alphabetic characters of the String, with cach alphabetic character converted to lowercase if necessary. Your class should have a constructor that takes a single String, stripped version. The Character wrapper class contains methods named isLetter () and toLowerCase() that you will find useful when you write strip(). See the Java API for information about these meth and a method called strip() that returns the Once you h ave written StrippedString, write a main class that prompts the user for the name of a text file. For each line of text in the file, create a StrippedString object, and then use the stripped version of the line to determine whether it is a palindrome. Your main class must have a function that takes a String as a parameter and uses the recursive algorithm to determine if it is a palindrome. Finally, print out the palindrome status of the line, followed by the original line of text from the file Suppose that the file "string_list.txt" contains the following linesStep 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