For the examples I was referring to our API documentation.
That might help answer both questions 1 and 2 for you.
As for question 3. A common way to do this would be to do the math when someone enters the information for both cost and revenue. You could use JQuery’s onChange or blur method as an example of how you could accomplish that part. Then at the top of the form you could use the onSubmit(myCall.php) method and reference the server side file that will hold your API call. So the API call will be on a a server side file where as the math and form would be done on a client side file which the end user sees. The client side file would then call the server side file to make the API call.
Note: you would replace the myCall.php with what ever the name of your file is. The file will get called when some one clicks the submit button at the bottom of the form.