/******************************************************************************
* AUTHOR : Aiden Stannard *
* STUDENT ID : 1284603 *
* Ch3, p146, #16: Interest Earned *
* CLASS : CS1A *
* SECTION : T/Th 6PM - 8:20PM *
* DUE DATE : 9/12/2026 *
******************************************************************************/
/******************************************************************************
* CALCULATE INTEREST EARNED
* ____________________________________________________________________________
* This program Calculates the amount of interest in dollars a user earned by
* prompting the user to enter the following info: Initial balance
* dollars(principal), Interest rate as decibal(rate), and the frequency the
* interest is compounded annually(T)
*
* Computation is based on the formula: (principal * pow((1+rate/T),T)) - principal
* ____________________________________________________________________________
* INPUT
* What was your initial balance?:__
* What is your interest rate as a decibal value?:__
* How many times is interest compounded per year?:__
*
*OUTPUT
* You've earned:__
*
******************************************************************************/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float principal; // Initial balance of account
float rate; // Interest Rate As a decibal value
float T; // Number of times interest is compounded over a year period
float amount; // Interest earned in dollars
cout << "What was your initial balance?: \n";
cin >> principal;
cout << "What is your interest rate as a decibal value?: \n";
cin >> rate;
cout << "How many times is interest compounded per year?: \n";
cin >> T;
amount = principal * pow((1+rate/T),T); // Calculates earning using inputs
cout << "You've earned: " << amount - principal << " Dollars In interest" << endl;
return 0;
}