cpp2_mult_f07 - CGS-2425 C+ EXAM 2, TEST FORM CODE "A",...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CGS-2425 C++ EXAM 2, TEST FORM CODE "A", SPECIAL CODE “72”, SPRING 2007 This exam is OPEN BOOK, OPEN NOTES, CLOSED NEIGHBOR. Cheaters will receive a ZERO on the exam. Assume <iostream> and <cmath> have been included prior to any partial C++ code. The next 3 questions refer to the following class. class Bond{ private: int faceValue; int rate; // return in percentage int numCoupon; // number of coupon payments per year int maturity; // in years public: Bond(void); Bond(int f, int r, int n, int m); int getRate() { return rate;} int getMaturity() {return maturity;} double couponValue(){return faceValue*(rate/100.00)/numCoupon;} double getPrice( double yield); double currentYield( double yield); }; Bond::Bond(void){ faceValue = 1000; rate = 10; numCoupon = 2; maturity = 10; } Bond::Bond(int f, int r, int n, int m){ faceValue = f; rate = r; numCoupon = n; maturity = m; } double Bond::getPrice( double yield){ double p = 0.00; double c = rate*faceValue/100.00; int n = numCoupon*maturity; double tmp = 1/pow(1+yield/(100.00*numCoupon), n); p = faceValue*tmp + c/(yield/100.00) * ( 1 - tmp); return p; } double Bond::currentYield( double yield){ double c = rate*faceValue/getPrice(yield); r e t u r n c ; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1. Suppose the main function contains the following declaration,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 7

cpp2_mult_f07 - CGS-2425 C+ EXAM 2, TEST FORM CODE "A",...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online