Code:
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Main {
static Scanner sc = new Scanner (System.in);
public static void main (String [] args) {
int number = 2;
String input;
while (true)
{
JOptionPane.showMessageDialog(null, number + "");
JOptionPane.showInputDialog(null,"Do you want to keep counting " + " Y or N");
if (input.equalsIgnoreCase("N"))
break;
number +=2;
JOptionPane.showMessageDialog(null, "\nWhew! That was close.\n");
}
}
}