Added Error handling functionality

Completed calculation function. If all parameters are valid function
will execute calculation and return true. Otherwise the function with
trigger an alert box telling the user the incorrect parameter and the
function will return false.