Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA: Write the method isPalindrome which should have the following signature: public class PalindromeTest { public static boolean isPalindrome( String s ) { boolean isPal

JAVA: Write the method isPalindrome which should have the following signature:

public class PalindromeTest {

public static boolean isPalindrome( String s ) {

boolean isPal = false; // assume that it is not

// code to determine if the string s is a palindrome

// If the default (as above) assumes the string is not a palindrome,

// the logic here should determine if it is and reassign the return

// variable isPal appropriately, or vice verse.

return( isPal );

}

}

**Encode the logic of the method:

1. Convert the string s to all lower case

2. Remove any character from the string which is neither a letter nor a digit. Hint: use replace (....) to replace any non-letter non-digit by the empty String "".

3. Check if the string s is a paindrome by checking to see if each letter is the same as the letter in its "mirror image" position; for example "Taco Cat" and "Toot!" are palindromes.

**Test your code on atleast the following palindromes:

- A man, a plan, a canal, Panama!

- Go hang a salami, I'm a lasagna hog!

- Campus Motto: Bottoms up, Mac!

- 7/1/17

- Are we not pure "No sir!" Panama's moody Noriega brags. It is garbage! Irony dooms a man; a prisoner up to new era.

**Note that the last quote may cause a problem because there are various kinds of smart quotes which are different from the simple ASCII double quotes; if all the others work and this one doesnt, dont worry about it!

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

Use service tiering to manage the customer base and build loyalty.

Answered: 1 week ago