Question: Stuck on homework for program from scratch: Write a method with the following header to display an integer in reversed order: public static int reverse

Stuck on homework for program from scratch:

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... 1. Find the length of the integer 2. Extract each digit 3. 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

CODE:

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"); } }

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!