You need to write code in javascript / ajax to create a calculator - the good thing is that you do not need to calculate the result. However you need to validate the input.
Please see attachment for a detailed description and a mockup of the way it should look.