Question: Problem Specifications: The Palindrome class Target: This Java program will read in a string from users input, and decide whether this string is a palindrome

Problem Specifications: The Palindrome class Target:

This Java program will read in a string from users input, and decide whether this string is a palindrome or not. The result (whether or not a palindrome) will be printed out onto the screen.

A palindrome is a word, phrase, or sequence that reads the same backward as forward.

For example:

madam

racecar

civic

kayak

Specifications:

In addition to the main method, you need to create another method

isPalindrome()

main Method

a) The main method should create a Scanner object. The main method will use this object to ask the user to input a non-empty string.

b) The main method will then call the isPalindrome method, and pass it the user-entered string as an argument.

c) The main method will then print the returned value from the isPalindrome method onto the screen, telling the user whether the input string is a palindrome or not

isPalindrome Method

a) The isPalindrome method accepts the string argument from the main method and then decides whether this string is a palindrome or not.

b) The isPalindrome method has one return value, which is a boolean value. If the string is a palindrome, return true; if it is not a palindrome, return false.

c) There are many algorithms to decide whether a string is a palindrome or not. Here follows are two of them.

Algorithm:

1) Create a new string that is in a reversed order of the original string. Then decide whether these two strings are equal to each other. If equal, the string is a palindrome; otherwise, not a palindrome.

2) Compare the counter-part characters in the original string. For example, for a palindrome string, its first character should be equal to the last character; the second character should be equal to the second last character, and so on. If any of these counter-part characters are not equal to each other, the string will not be a palindrome.

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!