Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions