Question: IN JAVA // Ex: Think through how one could use the stack directly, // instead of first removing non-letters. Why is it difficult? import java.util.*;
IN JAVA
// Ex: Think through how one could use the stack directly, // instead of first removing non-letters. Why is it difficult? import java.util.*; public class Palindrome2 { public static void main (String[] argv) { // Oldest known recorded palindrome. String str = "Evil did I dwell; lewd I did live"; System.out.println ( str + " " + checkPalindrome(str) ); // Oldest reference. str = "Madam, I'm Adam"; System.out.println ( str + " " + checkPalindrome(str) ); // One of the most famous. str = "A man, a plan, a canal: Panama"; System.out.println ( str + " " + checkPalindrome(str) ); // Not a palindrome, but a palingram: str = "He was, was he?"; System.out.println ( str + " " + checkPalindrome(str) ); } static String checkPalindrome (String str) { } }

In-Class Exercise 6: Download and modify Palindrome2.java so that blanks and other punctuation are ignored in testing for palindromes. Thus, the following should test correctly as palindromes: Evil did I dwell; lewd I did live 11 oldest known recorded palindrome A man, a plan, a canal: Panama I One of the most famous You will find the method character.isLetter) useful, as in if Character.isLetter (ch)) ..ch is a letter (not punctuation) // ch is something other than a' to 'z' or 'A' to 'z.. One way to solve the problem is to extract all the actual letters and put that into a list, and then to use the list in checking for palindromicity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
