JOptionPane Looping

I have an issue. My lecturer wants me to make a loop, with an input of JOptionPane and an output of console. How can I use loop for JOptionPane and send an output through console.

Here's my code:

int even = 0;
int odd = 0;
int e_e = 0;
int o_o = 0;

String a1 = JOptionPane.showInputDialog(null, "Type in 10 integer");

for (int counter = 0; counter < 10; counter++){
    int a = Integer.parseInt(a1);

    if (a % 2 == 0) {
        even++;
        e_e += a;
    } else {
        odd++;
        o_o += a;
    }
}

System.out.println("\n\nNumber of even numbers : " + even);
System.out.println("Number of odd numbers : " + odd);
System.out.println("Total of even numbers : " + e_e);
System.out.println("Total of odd numbers : " + o_o);

The problem with your current code is that you only ask the user one time to input a number but you actually seem to want 10 values. So you parse ten times the same value.

The solution is simple, put the dialog inside the loop (only changed the lines with comments):

int even = 0;
int odd = 0;
int e_e = 0;
int o_o = 0;

// No return type, just a message
JOptionPane.showMessageDialog(null, "Type in 10 integer");

for (int counter = 0; counter < 10; counter++) {
    // Dialog inside the loop, asking to
    // input a number in every iteration
    String value = JOptionPane.showInputDialog(null, "Type in "
        + (counter + 1) + ". value");
    int a = Integer.parseInt(value);

    if (a % 2 == 0) {
        even++;
        e_e += a;
    } else {
        odd++;
        o_o += a;
    }
}

System.out.println("\n\nNumber of even numbers : " + even);
System.out.println("Number of odd numbers : " + odd);
System.out.println("Total of even numbers : " + e_e);
System.out.println("Total of odd numbers : " + o_o);

I would try using a DO-WHILE loop with and an int[], example:

int size = 10;
int count = 0;

int[] yourNumbers = new int[size];

do {
    yourNumbers[count] = Integer.parseInt(JOptionPane.showInputDialog(null,
        "Your message here."));

    count++;
} while (count < 10);

This way you can loop through and grab all the numbers. Then you can use a FOR-LOOP to cycle through and print what you need

System.out.println("Even Numbers are: ");

for(int i = 0; i < yourNumbers.length; i++) {
    if (yourNumbers[i] % 2 == 0) {
        System.out.println(yourNumbers[i]);
    } 
}

System.out.println("Odd Numbers are: ");

for(int i = 0; i < yourNumbers.length; i++) {
    if (yourNumbers[i] % 2 != 0) {
        System.out.println(yourNumbers[i]);
    } 
}