home *** CD-ROM | disk | FTP | other *** search
- // Dave Wilson
- // 12-10-94
-
- //==============================================
- #ifndef _FINANCE_
- #include "Finance.h"
- #endif
-
- #define __NOSTRING__ // so exception file doesn't generate errors when include iostream
- #include <IOStream.h> // for cout
-
- //==============================================
- void SavingsTests();
- void LoanTests();
-
- //----------------------------------------------
- void
- SavingsTests()
- {
- short compoundsPerYear;
- short paymentsPerYear;
- double years;
- double annualInterestPercent;
- double payment;
- double presentValue;
- double savings;
-
- // H-P 67 standard Pac, p 05-04
- presentValue = 155.0;
- annualInterestPercent = 5.75;
- compoundsPerYear = 12;
- years = 9;
- savings = FutureValue(presentValue,
- annualInterestPercent,
- compoundsPerYear, years);
- cout << "savings (one payment) = " << savings << endl;
-
- // H-P 67/97 Business Decisions Pac, p. 11-02
- payment = 95;
- paymentsPerYear = 4;
- compoundsPerYear = 12;
- annualInterestPercent = 5.0;
- years = 7;
- savings = FutureValueWithPayments(payment,
- paymentsPerYear, compoundsPerYear,
- annualInterestPercent, years);
- cout << "savings (regular payments) = " << savings << endl;
-
- // H-P 67/97 Business Decisions Pac, p. 11-02
- payment = 157.78;
- paymentsPerYear = 12;
- compoundsPerYear = 4;
- annualInterestPercent = 5.25;
- years = 2;
- savings = FutureValueWithPayments(payment,
- paymentsPerYear, compoundsPerYear,
- annualInterestPercent, years);
- cout << "savings with payments = " << savings << endl;
-
- // H-P 67 standard Pac, p 05-05
- payment = 231.00;
- annualInterestPercent = 5.0;
- paymentsPerYear = 12;
- years = 20;
- presentValue = AnnuityPresentValue(payment,
- annualInterestPercent,
- paymentsPerYear, years);
- cout << "annuity present value = " << presentValue << endl;
-
- // H-P 67 standard Pac, p 05-05
- double annuity = 35000.00;
- double monthlyWithdrawal = 231.0;
- annualInterestPercent = 5.0;
- years = AnnuityMonths(annuity, monthlyWithdrawal,
- annualInterestPercent) / 12.0;
- cout << "years of withdrawal = " << years << endl;
- }
-
- //----------------------------------------------
- void
- LoanTests()
- {
- double amountBorrowed;
- double annualInterestPercent;
- double monthlyPayment;
- double payment;
- double years;
-
- // H-P 67 Standard Pac, p 05-05.
- amountBorrowed = 30000.0;
- annualInterestPercent = 9.0;
- years = 30;
- monthlyPayment = Payment(amountBorrowed,
- annualInterestPercent, years);
- cout << "monthly payment = " << monthlyPayment << endl;
-
- monthlyPayment = 241.39;
- annualInterestPercent = 9.0;
- years = 30;
- amountBorrowed = LoanAmount(monthlyPayment,
- annualInterestPercent, years);
- cout << "amount borrowed = " << amountBorrowed << endl;
-
- amountBorrowed = 30000;
- monthlyPayment = 241.39;
- annualInterestPercent = 9.0;
- years = LoanMonths(amountBorrowed, monthlyPayment,
- annualInterestPercent) / 12.0;
- cout << "years = " << years << endl;
-
- // H-P 67 Standard Pac, p 05-06.
- amountBorrowed = 3600;
- monthlyPayment = 100.0;
- annualInterestPercent = 10.0;
- years = 3;
- double balloon = BalloonPayment(amountBorrowed,
- monthlyPayment,
- annualInterestPercent, years);
- cout << "balloon payment = " << balloon << endl;
- }
-
- //==============================================
- void
- main()
- {
- SavingsTests();
- cout << endl;
- LoanTests();
- }