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
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