Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA: Please follow all rules listed below and have the code be originally yours as I know this is already on chegg publicly I

In JAVA: Please follow all rules listed below and have the code be originally yours as I know this is already on chegg publicly I need unique code, I also need the last two questions answered at the bottom. Also please comment code if you can it really helps me, and make sure it prints out the output like it does in the example dialog! Thanks so much in advance, please do not submit a written picture of an answer but a typed response.

Implement a program which uses a recursive method that determines if a string entered by the user is a palindrome. A string is palindrome if it is the same forward as it is backwards, such as radar or Taco cat.

Here are assumptions about the recursive method

The method should ignore all spaces

The method should also ignore case

Assume if a string is less than two characters or is null that it is a palindrome

Do not use any loops or iteration that is not recursive

Hints:

Recursive methods generally attempt to solve a smaller problem then return the results of those in order to solve the larger one.

To recursively solve this always look at the first character and the last character. Only if they are equal do you recursively call the method again, but pass in a new string with the first and last character removed from the given string.

Some useful string methods but all may not be used in the solution

toUppercase(): makes all characters uppercased

toLowercase(): makes all characters lowercased

charAt(index): returns a character at the specified index

trim(): returns a string with leading and trailing whitespace removed

substring(startIndex,endIndex): returns a string from the starting index (inclusive or is included) to the ending index (exclusive or is not included).

Example Dialog:

Enter a word and I will determine if it is a palindrome

Taco Cat

The word "Taco Cat" is a palindrome

Questions:

Using the recursive method, write out the string that is being processed at each step if the word radar was entered. Do the same for Straw arts.

Write some simple code using the iterative method (using loops) to solve this same problem.

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Describe national efforts to improve the quality of health care.

Answered: 1 week ago

Question

How would you describe your typical day at work?

Answered: 1 week ago