Question: Please don't forget to give the yield function and the main function to execute the program. Thanks 6 Question 6 6.1 Up to now, all
Please don't forget to give the yield function and the main function to execute the program. Thanks
6 Question 6 6.1 Up to now, all the functions we have written are stand-alone funins, Hence both the functions price.from yieldd...) and yield.from-price... carry cumbersome baggage, in the sense of input arguments (F.c,n) for the face, coupon and number of coupons, respectively. The valaes of these parameters are not relevant to a bisection algorithm, and do not change during iteration. Nevertheless, they must be passed as inputs to yield from price(...), sothat they can be passed to price.from.yield(...) to value the bond 6.2 This suggests the use of object-oriented programming. We can encapsulate the values of (Fe,) in "Bond" object. The functions price-from-yield( ) and yield-from-Price ( ) can be methods of that Bond class. We shall also support bonds which are notnewly issued, so to 0 6.3 Let us design a simple Bond class. What are its internal data members? Clearly we must have the face. We also need the maturity. (In real life the maturity would be a date, but here we store it as a double, measured in years.) To make things more interesting, let us consider a bond with variable coupons G, paid on dates (ti nes) t., i = 1.2 ,n. Both c' and t, are of type double. Hence our data members are: 1. double face; 2. double maturity 3. std; : vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
