Question: Using programming language Java Write a method called reverseDigits that takes a long integer value and returns that number with its digits reversed. For example,

Using programming language Java

Write a method called reverseDigits that takes a long integer value and returns that number with its digits reversed. For example, given the value 7631, the method should return the value 1367 (as a long integer). Write a main() routing that enters a loop, in which the user is prompted and allowed to enter any long integer (0 to exit the loop), and the reverseDigits method is used to compute and return the reversed number. Print this from the main routine. See sample run below.

Sample Run (Sample user input is bolded)

Please enter a long integer (0 to quit): 123456

The number reversed is: 654321

Please enter a long integer (0 to quit): 8473625145

The number reversed is: 5415263748

Please enter a long integer (0 to quit): 23456789

The number reversed is: 98765432

Please enter a long integer (0 to quit): 123456789012345678

The number reversed is: 876543210987654321

Please enter a long integer (0 to quit): 0

Goodbye!

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!