Put the names of the input fields in, say, A1 to A4. Fill in the corresponding values in B1 to B4.
Put the right formula in, say, B6, and magically the answer will appear there once B1 through B4 are filled in. That's the way Excel works.
It's up to you to find the right formula.