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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!