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!

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

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;

• Posts: 382Member
Note that the following holds:
[code]
number % 10 = last digit
(number - last digit) / 10 = number with last digit removed
[/code]
• 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;
:
:
:
This should get you started...

import javax.swing.JOptionPane;

public class DigitExtractor{

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

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

}

}