Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

Use PSpice to obtain vo in the circuit of Fig. 5.101? 2 V 0

Answered: 1 week ago