Question: Write a java program. Palindrome is a string which is spelled the same way forwards and backwards (Example: abba). Write a program that will check

Write a java program.

Palindrome is a string which is spelled the same way forwards and backwards (Example: abba). Write a program that will check if a given string is a palindrome.

Test your program with the following strings:

"amanaplanacanalpanama"

"cattac"

"radars"

Requirements:

Do not use recursion

Run your program with the given strings and attach the output (screenshot) and the source files.

Use the program template provided below do not delete any code. Write your own code where specified without modifying the given program.

import java.util.Scanner;

public class Palindrome {

public static void main(String [] args)

{

System.out.print("Enter a String to check if it is a palindrome : ");

Scanner input = new Scanner(System.in);

String palindromeStr = input.nextLine();

boolean palindrome = isPalindrome(palindromeStr);

if(palindrome)

System.out.println(palindromeStr + " is a palindrome.");

else

System.out.println(palindromeStr + " is not a palindrome.");

}

public static boolean isPalindrome(String palindromeStr)

{

boolean result = false;

// Write your code to find the input is Palindrome or not?

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!