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

In WordswithPals.java, write a program that inputs a String via the Scanner clas

ID: 3602524 • Letter: I

Question

In WordswithPals.java, write a program that inputs a String via the Scanner class and ther prints whether or not the input String is a palindrome. In your check for palindromes, do not consider capitalization, spaces or punctuation marks (.,-!'"? ) when checking whether a string is a palindrome. Do not use a loop of any kind; you will lose many points if you do. You can use regular expressions if desired, but you will get no extra credit. Dropbox WordswithPals.java. Sample program output: Enter a string: Not a palindrome. Enter a string: That's a palindrome! Enter a string: That's a palindrome! rewarder A man, a plan, a canal, Panama! Was it a car or a cat I saw?

Explanation / Answer

As told the program is done without using any loop

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

{
String str=" "; //variable declaration
Scanner sc=new Scanner(System.in);

System.out.println("Enter a String :"); //aceepting the string from user
str=sc.nextLine();
  
String str2 = new StringBuffer(str).reverse().toString(); //reversing the //string


if (str.equals(str2)) //checking for palindrome
System.out.println("That's a palindrome");

else
System.out.println("Not a palindrome");
}
  

}

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