Using Java: According to Wikipedia\' a palindrome is a word, phrase, number, or
ID: 3763072 • Letter: U
Question
Using Java:
According to Wikipedia' a palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction. Famous examples include "Amore, Roma", "A man, a plan, a canal: Panama" and "ZEROREZ". Problem. Write an application, is Palindrome, in Java that will take a string input from a user and determine whether or not the string is a palindrome. Input: String Output: Original String, Reverse String, Whether or Not a palindrome Assumptions: Ignore spaces and punctuation Additional Requirement: Use at least one Exception Handling Mechanism.Explanation / Answer
public class Palindrome
{
public static boolean isPalindrome(String arg0)
{
if(arg==null)
return false;
int n=arg0.length();
for(int i=0;i<n/2;i++)
{
if(arg0.charAt(i)!=arg0.charAt(n-1-i))
{
return false;
}
}
public static void main(String[] args)
if(isPalindrome(“Zerorez”))
{
System.out.println(“palindrome”);
}
else
{
System.out.println(“not a palindrome”);
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.