Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an interactive program Palindrome.java that prompts the user “Give me a Pa

ID: 3627031 • Letter: W

Question

Write an interactive program Palindrome.java that prompts the user “Give me a Palindrome?”.The program will find out if the input word or sentence is a palindrome or not The program ask the user over and over “give me a palindrome?” If the user does not type anything the program will display”not a Palindrome”and he/she may terminate the loop by typing “quit” .
1 Palindrome is case-insensitive .
2 Palindrome does not care about white spaces.
3 Palindrome does not care about punctuation.
4 palindrome does not care about alpha numeric.
5 everything else should be filtered filterize.
6 Need one or more methods to filterize the input.
For example, if the user typed :Never odd or even!!!!!
out put will be Never odd or even!!!! is a palindrome .However if the user typed:XXNever odd or even !!!! the out put should be :XXNever odd or even!!!! is not a palindrome.
In other words the program should echo back.
7.Filterize the above Palindrome to display NEVERODDOREVEN is a palindrome.
always check if the return is a palindrome.
8.Use if(reverse(pal).equals(pal));to compare.Or use boolean method:boolean isPalindrome(String pal)
Use main to call your methods.
main should be concise

Test your program with NOON,MADAM ,MOM
etc.

Explanation / Answer

please rate - thanks

import java.util.*;
public class palindrome
{
public static void main(String args[])

{
Scanner in =new Scanner(System.in);
boolean palin;
String input,reveresed;
System.out.print("Enter a string(quit to exit): ");
input=in.nextLine();
while(input.compareToIgnoreCase("quit")!=0)
{
if(isPalindrome(input))
   System.out.println(input+" is a Palindrome");
else
    System.out.println(input+" is not a Palindrome");
System.out.print("Enter a string(quit to exit): ");
input=in.nextLine();

}
}
public static boolean isPalindrome(String input )
{int i=0,j;
boolean y=false;
input=filter(input);
j=input.length()-1;
while(input.charAt(i)==input.charAt(j)&&i<=j)
      {i++;
       j--;
       }
if(i>j)
    y=true;
return y;
}
public static String filter(String input)
{String str="";
int i;
for(i=0;i<input.length();i++)
   if(Character.isLetter(input.charAt(i)))
        str=str+Character.toLowerCase(input.charAt(i));
return str;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote