in reply to Homework: simple calculator

It looks to me like you're very nearly there. All you seem to be missing is how to exit your loop when 'q' is pressed. last can help you with that.