It depends if you like a JOptionPane for each iteration of the loop or not.

If you do, I have no clue how to do the %3d with JOptionPane, but you'd

do this:
...