//Yasmine Cervantes CS1A Ch. 5, P.296, # 16
//
/*******************************************************************************
*
* CALCULATING A SAVINGS ACCOUNT BALANCE
*_______________________________________________________________________________
* This program will calculate the balance of a savings account at the end of a
* certain period of time. It will use annual interest rates, the starting
* balance, and the total amount of months that have passed since the account was
* established.
* ______________________________________________________________________________
* INPUT:
* initialBalance - 10,000
* annualInterest - 0.10
* numberofMonths - 36
* monthlyDeposit - 500 // user inputs
* monthlyWithdrawal - 200 // user inputs
*
*
* OUTPUT:
* monthlyInterest - annualInterest / 12
* totalDeposits - monthlyDeposit * numberofMonths
* totalWithdrawn - monthlyWithdrawn * numberofMonths
* totalinterestEarned - monthlyWithdrawn * numberofMonths
* endingBalance - (initialBalance - totalmonthlyWithdrawn +
* totalmonthlyDeposit) + totalinterestEarned
*
*
*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
//Declaring Variables
double initialBalance = 10000;
double annualInterest = 0.10;
double numberofMonths = 36;
double monthlyDeposit = 0;
double monthlyWithdrawn = 0;
//Input
cout << "Please insert amount of cash deposit for the month" << endl;
cin >> monthlyDeposit;
cout << "Please insert amount of cash withdrawn for the month" << endl;
cin >> monthlyWithdrawn;
// Calculations & output
double totalmonthlyDeposit = monthlyDeposit * numberofMonths;
cout << "Your total amount of monthly deposits is: " << totalmonthlyDeposit
<< endl;
double totalmonthlyWithdrawn = monthlyWithdrawn * numberofMonths;
cout << "your total amount of monthly withdrawals is: " << totalmonthlyWithdrawn
<< endl;
double monthlyInterest = annualInterest / 12;
cout << "Your monthly interest is: " << monthlyInterest << endl;
double totalinterestEarned = monthlyInterest * initialBalance;
cout << "Your total amount of interest earned is: " << totalinterestEarned
<< endl;
double endingBalance = (initialBalance - totalmonthlyWithdrawn + totalmonthlyDeposit)
+ totalinterestEarned;
cout << "Your ending balance is: " << endingBalance << endl;
return 0;
}