Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Paragraph Styles Write a method with the following header to display an integer

ID: 3863991 • Letter: P

Question

Paragraph Styles 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 S4321 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 import java util scaoner public class Nu public static int reverse (int number FixME 1 (50 points): Complete the method to return the number in reversed order 4

Explanation / Answer

import java.util.Scanner;

public class Reversenumber {

   public static int reverse(int number){
       int reverseNum = 0;
       String strNum = Integer.toString(number);
       int mul = 1;
       for(int i=0;i<strNum.length();i++){
           int digit = Character.getNumericValue(strNum.charAt(i));
           reverseNum += digit*mul;
           mul *= 10;
       }
       return reverseNum;
   }
   public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
       System.out.println("Enter an Integer :");
       int number = scanner.nextInt();
       System.out.println(""+number+" is in reverse order is "+reverse(number));
       scanner.close();

   }

}

//====================== OUTPUT ==============================//

Enter an Integer :
6362
6362 is in reverse order is 2636