Question
Write two methods with the following headers: // Return the reversal of an integer, i.e., reverse(123) returns 321 public static int reverse(int number) // Return
Write two methods with the following headers:
// Return the reversal of an integer, i.e., reverse(123) returns 321
public static int reverse(int number)
// Return true if number is a palindrome
public static boolean isPalindrome(int number)
Use the
reverse
method to implement the
isPalindrome
method. A number is a
palindrome if its reversal is the same as itself.
Write a java program that prompts the user to enter a positive
integer, calls the
reverse
method with this positive integer, displays the integer in reverse
order, and reports whether the integer is a palindrome.
For example, the output of your program should look exactly like the following when the
user enters 123:
Enter a positive integer: 123
The number 123 in reverse order is 321.
The number 123 is not a palindrome.
And when the user enters 121, the output of your program should look exactly like the
following:
Enter a positive integer: 121
The number 121 in reverse order is 121.
The number 121 is a palindrome.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started