JOptionPan.showInputDialog() i believe returns a null string if the cancel button is pushed. You need to check that before you try to parse the number into an int. To exit a program completely, you...