Question: I would like the javascript to catch integers as a invalid input. Can that be done? 1 import java.util.Scanner; 3 public class Palindrome 4 args)

I would like the javascript to catch integers as a invalid input. Can that be done?

I would like the javascript to catch integers as a invalid input.

1 import java.util.Scanner; 3 public class Palindrome 4 args) i public static void main(String System.out.print("Enter a sentence or word to check"; Scanner reader new Scanner(System. in); String str = reader.next Line(); 10 boolean result-palindrome(str); 12 13 14 15 16 17 18 19 20 21 if(result) System.out.println(str" IS a palindrome!"; else i System.out.println(strIS NOT a palindrome!"); reader.closeO; 23 24 25 26 27 28 29 30 31 32 //Method used public static boolean palindrome(String str) String reverse ""; boolean resultfalse ""); String Str= str. replaceAll("[^a-zA-Z) ", Str = Str. toLowerCase(); int i Str.lengthO) -1; i -0; i--) reverse-reverse Str.charAt(i); for 34 35 36 37 38 if (Str.contentEquals(reverse))[ result true; } else [ 39 40 41 42 43 resultfalse; return result

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!