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

A palindrome is any word, phrase, or sentence that reads the same forward and ba

ID: 3632572 • Letter: A

Question

A palindrome is any word, phrase, or sentence that reads the same forward and backward.

Create a PalindromeTester Program so that the spaces and punctuations are not considered when determining whether a string is a palindrome.The program must ask user to input the word. The program must stop if user provides a black line. (example of program running below). This involves loops, nested loops.
------------------------------
The following are sample interactions that occur when running the program:

enter a word, phrase, or sentence (blank line to stop):
<enter>
Thank you for using PalindromeTester.

enter a word, phrase, or sentence (blank line to stop):
Ada
palindrome

enter a word, phrase, or sentence (blank line to stop):
This homework is easy
Not a palindrome

enter a word, phrase, or sentence (blank line to stop):
W , ' a " Y . y;a w
palindrome
--------------------------

Explanation / Answer

please rate - thanks

import java.util.*;
public class palindrome
{
public static void main(String args[])
{
Scanner in =new Scanner(System.in);
String input;
System.out.println("enter a word, phrase, or sentence (blank line to stop):");
input=in.nextLine();
while(input.length()!=0)
{
if(isPalindrome(input))
   System.out.println("palindrome");
else
    System.out.println("NOT a palindrome");
System.out.println("enter a word, phrase, or sentence (blank line to stop):");
input=in.nextLine();

}
System.out.println("Thank you for using PalindromeTester.");
}
public static boolean isPalindrome(String input )
{int i=0,j;
boolean y=false;
j=input.length()-1;
while(Character.toUpperCase(input.charAt(i))==Character.toUpperCase(input.charAt(j))&&i<=j)
     {do
        {
        i++;
        }while(!Character.isLetter(input.charAt(i)));
        do
        {
        j--;
        }while(!Character.isLetter(input.charAt(j)));
    }
if(i>j)
    y=true;
return y;
}
}

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