//Andres Guzman CSC5 Chapter 3, P. 146, #16
//
/**************************************************************
*
* ANNUAL SAVING BALANCE CALCULATION
* ____________________________________________________________
* This program will calculate the compound interest
* Computation is based on the formula:
* Amount = Principal × (1 + Rate/T)^T
____________________________________________________________
* INPUT
* rate : the interest rate
* com : times compounded(1, 2, 4, 12, 365)
* principal : invested amount
* OUTPUT
* interest : the amount multiplied by rates
* amount : total amount in savings
**************************************************************/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main ()
{
float principal; //Input for invested number
float rate; //Input for rate percentage
float com; //Input for time compound
//
//Output results
cout << "Interest Rate: ";
cin >> rate;
cout << "\nTimes Compounded: ";
cin >> com;
cout << "\nPrincipal: $ ";
cin >> principal;
//
//Computation of formula
rate/=100; //Output to turn rate into mathematical equivalent
float amount = principal * (pow((1+ (rate/com)),com )); //Compound interest
float interest = amount - principal; //Output sum after rate
//
//Output results
cout << fixed << setprecision(2) << "\nInterest: $" << interest;
cout << "\nAmount in Savings: $" << amount;
return 0;
}