Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA eclipse. Please help! A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able

JAVA eclipse. Please help!

A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes:

Able was I, ere I saw Elba

A man, a plan, a canal, Panama

Desserts, I stressed

Kayak

Write a boolean method that uses recursion to determine whether a String argument is a palindrome. The method should return true if the argument reads the same forward and backward. Demonstrate the method in a program.

The program should ask the user to enter a string, which is checked for palindrome property. The program displays whether the given input is a palindrome or not, then prompts the user to enter another string. If the user enters QUIT (case insensitive, then exit the program).

View required output

Test Case 1

Standard Input
Desserts, I stressedENTER KayakENTER quitENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is a palindrome. Please enter a string to test for palindrome or type QUIT to exit: The input is a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

Test Case 2

Standard Input
dadENTER quitENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

Test Case 3

Standard Input
momENTER QuitENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

Test Case 4

Standard Input
helloENTER quiTENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is not a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

Test Case 5

Standard Input
b,a,dENTER quitENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is not a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

Test Case 6

Standard Input
Able was I, ere I saw ElbaENTER quitENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

Test Case 7

Standard Input
A man, a plan, a canal, PanamaENTER quitENTER 
Please enter a string to test for palindrome or type QUIT to exit: The input is a palindrome. Please enter a string to test for palindrome or type QUIT to exit: 

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

More Books

Students also viewed these Databases questions