Here's some code I use for testing OP's code where it uses JOptionPane dialog prompts to enter data.
The retVals[] array needs to be filled with the answers for the prompts.


...