As the stacktrace shows it is not able to convert a string to integer here :
credits = Integer.parseInt(input);
Your while loop checks if input has value 'Q'. But the problem is that you update the value of input inside the while code itself. So when you provide value Q the loop will complete the current iteration and break while checking for the next iteration. I suggest you to put another input at the end of the loop.
input = JOptionPane.showInputDialog(null,"Do you want to quit? Press Q" ,"Do you want to quit? Press Q ",1);