Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Like in Exercise 4 , your task is to develop a method called isPalindrome ( ) that takes a string as a parameter. If the
Like in Exercise your task is to develop a method called isPalindrome that takes a string as a parameter. If the string is a palindrome a word that is spelled the same forward and backward then the method will return a boolean of true. If the string is not a palindrome, then false is returned. The difference between this exercise and Exercise however, is that you will need to use a helper method called reverse within isPalindrome The reverse method takes a string as a parameter and reverses it Then the reversed string is returned.
Remember that capitalization matters. For example, "Level" would not be considered a palindrome because uppercase L and lowercase l are not the same.
Existing Code:
import java.util.;
public class Exercise
public static String reverseString x
String y ;
for int i xlength; i ; i
y xcharAti;
return y;
add code below this line
add code above this line
public static void mainString args
String x args;
System.out.printlnisPalindromex;
Hint
Consider creating a new empty string and populating it with characters of the specified string in reverse order. Then check the two strings for equality. Remember that the method should return a boolean, therefore, you should declare a boolean variable and have that boolean change based on certain conditions. Then return that variable.
Requirements
You should not make any changes to the code that already exists. If you accidentally delete any existing code, you can copy and paste the entire program from above.
You must include the helper method reverse within your isPalindrome method; otherwise, you will not receive credit for your work!
The button below will compile and test the code with "Level"
Expected result : false
The button below will compile and test the code with "anna"
Expected output : true
The button below will compile and test the code with
Expected result : false
There is an exisinting question but it print out true for case "Level"
it should be false
The rest of the case works fine The code is in Java
Thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started