Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I * Finish the program below. Write a Java method to check if a given string is a palindrome or not. First convert given string

I*
Finish the program below.
Write a Java method to check if a given string is a palindrome
or not. First convert given string to lower case. Second
if given string is empty or size of one it is alpalindrome wqritas
Lastly, use a loop and two indicescto
second to last characters are the same
The method returns boolean
*/
// Convert the string to lowercase
// Check if the string is empty or has only onelcharacten sulav sht snimq nism al
}
// If the loop completes, the string is a palindrome return true;
public static void printIsPal(String str){
if (isPalindrome(str)){
System.out.print " is a palindrome");
} else {
}
System.out.print " is not a palindrome");
}
public static void main(String[] args){
String str1= "madam";
String str2= "a racecar";
printIsPal(str1);
}
printIsPal(str2);
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions