Question: Recursive method for recognizing a palindrome in java. Your program should do the following by modifying the below code: mport java.util.Scanner; public class Lab6{ public

Recursive method for recognizing a palindrome in java.

Your program should do the following by modifying the below code:

Recursive method for recognizing a palindrome in java. Your program should do

mport java.util.Scanner;

public class Lab6{

public static void main(String[] args){ /******************************************************** Palindrome */ if (!isaPalindrome("satanoscillatemymetallicsonatas")) System.out.println("You have a bug in your code!"); else System.out.println("check for palidrome ok"); Scanner console = new Scanner(System.in); System.out.print("Input a string >"); String line = console.nextLine(); while (!line.equals("")){ if (isaPalindrome(line)) System.out.println(line+ "is a palindrome"); else System.out.println(line+ "is *not* a palindrome"); System.out.print("Input a string >"); line = console.nextLine(); } }

/** method to determine whether the specified string is a palindrome * @param expr string * @return true if the specified string is a palindrome, otherwise false. */ public static boolean isaPalindrome(String expr){ // TO COMPLETE }

} the following by modifying the below code: mport java.util.Scanner; public class Lab6{

1. prompts the user to input a string 2. recursively check if the string is a palindrome; 3. print out a message accordingly; until an empty string is input. The recursive method to check the palindrome must have the following signature: public static boolean isaPalindrome (String expr) . The String class contains methods to obtain the length of a string; obtain the char at a specified position of a string; obtain a substring of a string; check the latest java api to find details of the String class. To obtain the input, use the method nextLine of the Scanner class. import java.util.Scanner public class Lab6 public static void main(String[] args) if (!isaPalindrome ("satanoscillatemymetallicsonatas")) else Palindrome System.out.println("You have a bug in your code!"); System.out.println("check for palidrome ok"); Scanner console -new Scanner(System.in); System.out.print("Input a string >"); String line -console.nextLine); while (!line.equals(""))I if (isaPalindrome(line)) System.out.println(line+ "is a palindrome"); else System.out.println(line "is not* a palindrome"); System.out.print("Input a string >"); line -console.nextLine () /kok method to determine whether the specified string is a palindrome k @param expr string k @return true if the specified string is a palindrome, otherwise false public static boolean isaPalindrome(String expr) ITO COMPLETE

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!