I have this problem in school, and I have no idea how to start.
Here are the directions:
Write a method with the following header to display an integer in reversed order:
public static int reverse (int number)
Example Output:
Enter an integer: 12345 in reversed order is 54321
Note:
You will need to...
- Find the length of the integer
- Extract each digit
- In the event that the expected outputs do not match the output tests or the code is incomplete that the program fails to run, points will be given to the sections that the codes are written properly
~~~~~~~~~~~~~~~~~~~~~~~~~
And here is the skeleton that they give me to work with:
import java.util.Scanner;
public class ReverseNumber {
public static int reverse (int number) {
// FIXME 1 (50 points): Complete the method to return the number in reversed order
}
public static void main (String[] args) {
// FIXME 2 (25 points): Write the statements to prompt the user enter an integer and store it in an integer variable
System.out.println("Enter an integer: ");
/*
FIXME 3 (25 points): Write the statements to call the reverse (int number) method
Print the result in the required format
*/
System.out.println("12345 in reverse order is 54321");
}
}
I need to know what to put in here and where to put it in order to get it to output some thing like the example. Don't change the skeleton, just add to it.