/* * This program models an investment earning simple interest. * * An investment earning simple interest has three attributes: * present value (the amount of money invested), the nominal * annual interest rate, and the term (the number of years). * Calculated values include the total amount of interest * earned and the future value (the value of the investment * at the end of its term). * * Aug 2006 * D. Searls * Asbury College */ #include <iostream> // Provides input/output capabilities #include <iomanip> // Provides output formatting using namespace std; int main() { double presentValue; // The value at the beginning double nominalRate; // Nominal annual rate int years; // The term of the investment double interest; // The amount of interest earned double futureValue; // The value at the end // Display instructions. cout << "This program models an investment earning simple interest." << endl; cout << "You will be asked to enter the present value, the nominal" << endl; cout << "annual interest rate, and the term (in years)." << endl << endl; // Input the present value, the nominal rate and // the number of years. cout << "Enter the present value: "; cin >> presentValue; cout << "Enter the nominal annual rate (as a %): "; cin >> nominalRate; cout << "Enter the number of years: "; cin >> years; cout << endl; // Calculcate the interest and the future value. interest = presentValue * nominalRate/100.0 * (double)years; futureValue = presentValue + interest; // Display a report for this investment. cout << fixed << setprecision(2); cout << "Present Value: $" << presentValue << endl; cout << "Nominal Rate: " << nominalRate << "%" << endl; cout << "Term: " << years << " years" << endl; cout << "Interest: $" << interest << endl; cout << "Future Value: $" << futureValue << endl; cout << endl; cout << endl; return 0; }