Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8751749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:06:27+00:00 2026-06-13T13:06:27+00:00

So, I’m supposed to write a program determining Ermips . I’ve got the rest

  • 0

So, I’m supposed to write a program determining Ermips. I’ve got the rest figured out, but I’m not sure how to reverse the number correctly. I’m supposed to use an array to reverse it.

For example, the number 357.

I use the mod operator to take the last digit and put it in the first index of the array.

357%10 = 7

myArray[0] = 7

357/10 = 35 for a remainder

Use the remainder 35 to start over.

35%10 = 3

myArray[1] = 3

35/10 = 3 for a remainder

etc. …

I need to basically loop this so I can do any length number to reverse it.

Then, after I have that array, display the array to produce the number in reverse….753.

public class Reverse {
        public static void main(String[]args) {
        int n = 357;
        int MAX_NUMBERS = 20;
        int currentNumber = 0;
        int reverseNumber = 0;
        int remain = 0;
        int sum = 0;

                  int [] holdDigits = new int [MAX_NUMBERS];


        int exp = holdDigits.length;
        System.out.println("exp: " + exp);
        int index = 0;

                  //sum array
       int count = holdDigits.length;
       while (count > 0){
        holdDigits[index] = n%10;
        System.out.println(index + "index: " + holdDigits[index]);
        n = n/10;
        System.out.println("remainder: " + n);

        count--;

        index++;
        }

        while (index < holdDigits.length){
        reverseNumber += holdDigits[index]*Math.pow(10,count-exp);
        index--;
        System.out.println("sum so far: " + sum);
        }

    System.out.println("Number reversed: " + reverseNumber);
         }//end of main
    }//end of class

Totally figured it out now, thanks to Yogendra Singh !
Check it out:

    public class Reverse2 {

    public static void main(String[]args) {


    int n = 76495;
    int MAX_NUMBERS = 20;
    int reverseNumber = 0;
    int index = 0;  

    //declare an array to hold the digits while reversing
    int [] holdDigits = new int [MAX_NUMBERS];

    //the exponent is the number of spaced used in the array
    int exp = holdDigits.length;  

    //while the number is greater than 0, use mod to put the right-most
    //digit in index 0, divide the remaining number and increase the index
    //to put it in the next open slot of the array.
    while (n > 0){
        holdDigits[index] = n%10;
        n = n/10;
        index++;
    }

    //decrease the index by one so it doesn't add the remaining zero as
    //a placeholder in the number
    index--;

    //count is the index because below, you subtract it, making the display
    //of the array reversed.
    int count= index;

    //while the index is greater than zero, by starting at the last filled 
    //slot of the array, the reverse number is added onto each time by 
    //multiplying the number times 10 to the power of whichever place it
    //is which happens to be the index. 
    //EXAMPLE: to turn 7 into 700, multiply by 7x10^3
    while (index >= 0 ){
        reverseNumber += holdDigits[count-index]*Math.pow(10,index);

        //lower the index to do the next number of the array
        index--;
    }

    System.out.println("Reversed number: " + reverseNumber);


    }//end of main


}//end of class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:06:28+00:00Added an answer on June 13, 2026 at 1:06 pm

    There are some issues in the code as below:

    1. Run the first loop until remainder of division is 0
    2. Count the digits found in the division process
    3. Reduce the index by 1 after first loop as it is post incremented by one in the while loop

    Sample corrected code could be as below:

        int exp = holdDigits.length;
        System.out.println("exp: " + exp);
        int index = 0;
        while (n > 0){
            holdDigits[index] = n%10;
            System.out.println(index + "index: " + holdDigits[index]);
            n = n/10;
            System.out.println("remainder: " + n);
            index++;
        }
        index--;
        int count= index;
        while (index >=0 ){
            reverseNumber += holdDigits[count-index]*Math.pow(10,index);
            index--;
            System.out.println("sum so far: " + sum);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.