Question: Write a program to read several lines from a file called H.in. For each line, check whether it is a palindrome. For each line read

Write a program to read several lines from a file called H.in. For each line, check whether it is a palindrome. For each line read from the file, print only the lines that are palindromes. Recall that a palindrome is a string that is the same backwards and forwards, ignoring spaces and punctuation. Some example palindromes are radar and I, Madam, I made radio. So I dared! Am I mad? Am I?? You may use theremoveWS method from Lab. Your palindrome checking method must be recursive. In JAVA:

removeWS :

public static String removeWS(String a) { if (a.length() == 0) return a; String b = Character.isLetterOrDigit(a.substring(0, 1).charAt(0)) ? a.substring(0, 1) : ""; return b + removeWS(a.substring(1)); } }

H.in:

You must be the change you want to see in the world Sore was I, ere I saw Eros. A man, a plan, a canal -- Panama Never a foot too far, even. BORROW - OR ROB? Euston SaW I was not Sue. THIS IS JUST A TEST. "Stop!" nine myriad murmur. "Put up rum, rum, dairymen, in pots." Live on evasions?! No, I save no evil. Red Roses run no risk, sir, on nurses order. The best way out is always through........

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!