Need HELP!!! I have a program due tomorrow!! HELP!!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need HELP!!! I have a program due tomorrow!! HELP!!!

Skunk2nRSkunk2nR Posts: 1Member
I have to write a program that reads in an integer and breaks it into a sequence of individual digits in reverse order. For example, the input 16384 is displayed as

4
8
3
6
1

You may assume that the input has no more than five digits and is not negative.

Define a class DigitExtractor:

public class DigitExtractor
{
.......


}

Ok. What how am I suppose to write this? He wants a DigitExtractor.java file and a DigitExtractorTest.java file.

Where am I suppose to put the input code at? Help me once more. Thanks.


We have to use JOptionPane, so I guesss we import javax.swing.JOptionPane;

PLEASE Help! I'm still stuck and its due tomorrow!!!

Comments

  • IllcoIllco Posts: 382Member
    Note that the following holds:
    [code]
    number % 10 = last digit
    (number - last digit) / 10 = number with last digit removed
    [/code]
  • beancounterbeancounter Posts: 88Member
    : I have to write a program that reads in an integer and breaks it into a sequence of individual digits in reverse order. For example, the input 16384 is displayed as
    :
    : 4
    : 8
    : 3
    : 6
    : 1
    :
    : You may assume that the input has no more than five digits and is not negative.
    :
    : Define a class DigitExtractor:
    :
    : public class DigitExtractor
    : {
    : .......
    :
    :
    : }
    :
    : Ok. What how am I suppose to write this? He wants a DigitExtractor.java file and a DigitExtractorTest.java file.
    :
    : Where am I suppose to put the input code at? Help me once more. Thanks.
    :
    :
    : We have to use JOptionPane, so I guesss we import javax.swing.JOptionPane;
    :
    : PLEASE Help! I'm still stuck and its due tomorrow!!!
    :
    :
    This should get you started...

    import javax.swing.JOptionPane;


    public class DigitExtractor{


    public static void main(String[] args){
    String reply = JOptionPane.showInputDialog( null, "Enter :" );
    int number = Integer.parseInt(reply);
    if (number > 99999){
    System.out.print("You have entered an incorrect number");
    }
    char[] result = reply.toCharArray();

    for(int i = 4; i>-1; i--){
    System.out.println(result[i]);
    }

    }

    }
Sign In or Register to comment.