Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function to do the inverse calculation. (This should be easy.) The input

ID: 3872593 • Letter: W

Question

Write a function to do the inverse calculation. (This should be easy.) The inputs are (i) today's cashflow F_0, (ii) future cashflow F_1, (iii) today's time f_0, (iv) future time t_1. The outputs are (v) discount factor d, (vi) continuously compounded interest rate r. As above, the value of r should be expressed as a percentage, if the interest rate is 5% then r = 5. The function signature is int df_and_r(double F0, double F1, double t0, double t1, double & df, double & r): The return type is "int" because we want some validation checks. If t_1 - t_0 equals zero, then set d = 0 and r = 0 and exit with a return value -1. If F_0

Explanation / Answer

Dear Student,

below i have written the complete function as per the requirement and considering the sample function. I have also include the comments so that you can understand it better.

---------------------------------------------------------------------------------------------------------------------------------------

function:

//start of function

//return type of the function is int


int df_and_r(double F0, double F1, double t0, double t1, double &d, double &r);

{

//if t1-t0 = 0 then here setting d =0, r =0 and exiting with a return value -1.

if(t1 - t0 == 0)

{

d = 0;

r = 0;

return -1;

}

//if F0 <= 0 OR F1 <= 0, then here setting d =0, r =0 and exiting with a return value -2.

if((F0 <= 0) || (F1 <= 0))

{

d = 0;

r = 0;

return -2;

}

//if everything is fine then return with a value zero

return 0;

}//end of function


-----------------------------------------------------------------------------------------------------------------------------------------

Kindly Check and Verify Thanks...!!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote