hi. I'm noe struggling with using JOptionPane. The question which I was assigned to do this.
You are to write a program that will accept a positive integer in the range 0 to 9999, i.e. the integer has a maximum of 4 digits.s input and then outputs the digits one per line.
The input/output must be via dialog boxes. The following are examples of the input/output you should produce:
I don't know how to put the output but I will type it down.
Homework 3(The title)
Enter a positive 4 digit number
[empty box where you can type the number] [Lets say 1234]
OK[Button] Cancel[Button]
Once click OK button, it will shows the next dialog
Homework3 Answer[Title]
The number was 1234
The digits are
1
2
3
4
OK[Button]
So far I got this codes
import javax.swing.*;
public class Homework3{
public static void main(String args[]){
String number;
number=JOptionPane.showInputDialog (null,"Enter a positive 4 digit");
JOptionPane.showMessageDialog(null,"The number was" + number);
}
}