Write a Java program to test for palindrome integers and strings. A number/string is a palindrome if its reversal is the same as itself. In the object class Palindrome, write the following methods: public int reverse(int number) - returns the reversal of an integer. public boolean isPalindrome(int number) - return true if the number received as parameter is a palindrome.  Use the reverse method to implement isPalindrome. Write a testPalindrome class that prompts the user to enter an integer and reports whether the integer is a palindrome. Example of output for input 1221: The number 1221 is a palindrome Example output for input 1234: The number 1234 is not a palindrome Example output for input 91419: The number 91419 is not a palindrome Expand the Palindrome object class by overloading the reverse and isPalindrome methods.  Do this by adding another reverse method that will reverse

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a Java program to test for palindrome integers and strings.

A number/string is a palindrome if its reversal is the same as itself.

In the object class Palindrome, write the following methods:

  • public int reverse(int number) - returns the reversal of an integer.
  • public boolean isPalindrome(int number) - return true if the number received as parameter is a palindrome.  Use the reverse method to implement isPalindrome.

Write a testPalindrome class that prompts the user to enter an integer and reports whether the integer is a palindrome.

Example of output for input 1221:

The number 1221 is a palindrome

Example output for input 1234:

The number 1234 is not a palindrome

Example output for input 91419:

The number 91419 is not a palindrome

Expand the Palindrome object class by overloading the reverse and isPalindrome methods.  Do this by adding another reverse method that will reverse and return the reversed string.  Also add another isPalindrome that will receive a string instead of an integer to test for being a palindrome. 

In the test class, ask the user to enter a string and display the result. 

Example of output for the input dad:

The word dad is a palindrome

Example of output for the input add:

The word add is not a palindrome

Example of output for the input racecar:

The word racecar is a palindrome

Hint! Prompt the user first if they want to enter a word or a number, then continue based on their response.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education