Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Dillon Janakus
- //Computer Science 1
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <cmath>
- #include <fstream>
- #include <sstream>
- using namespace std;
- int main()
- {
- float startB= 0; //Starting balance
- float intRate= 0; //Interest Rate
- float monthsP= 0; //Number of months passed
- float depoM= 0; //Money deposited during each month
- float withM= 0; //Money withdrawn during the month
- float intP= 0; //Interest rate percent
- float totalD= 0; //Total deposited
- float totalI= 0; //Total
- float totalW= 0; //Total withdrawn
- float monthI= 0; //Monthly interest rate
- float total= 0; //Final balance
- cout << "Enter the starting balance of your account: ";
- cin>>(startB);
- while(startB<0)
- {
- cout<< "Negative numbers are not accepted, please try again: ";
- cin>>(startB);
- }
- cout<< "Enter the annual interest rate: ";
- cin>>(intRate);
- intP=(intRate/100);
- monthI=(intP/12);
- while(intRate<0)
- {
- cout<< "Negative numbers are not accepted, please try again: ";
- cin>>(intRate);
- }
- intP = (intRate/100);
- cout<< "Enter the number of months that have passed since the account ";
- cout<< "was established: ";
- cin>>(monthsP);
- while(monthsP<0)
- {
- cout<< "Negative numbers are not accepted please try again: ";
- cin>>(monthsP);
- }
- total=startB;
- cout<<endl;
- for(int m=1; m<=monthsP; m++)
- {
- cout<< "Enter the amount of money deposited during month "<<m<<": ";
- cin>> (depoM);
- while(depoM<0)
- {
- cout<< "Negative numbers are not accepted please try again: ";
- cin>>(depoM);
- }
- totalD+=depoM;
- total+=depoM;
- cout<< "Enter the amount of money withdrawn during month "<<m<<": ";
- cin>> (withM);
- while(withM<0)
- {
- cout<< "Negative numbers are not accepted please try again: ";
- cin>>(withM);
- }
- totalW+=withM;
- total-=withM;
- totalI+=(total*monthI);
- total+=(total*monthI);
- cout<<endl;
- }
- cout<< "Total deposited: $"<<totalD<<endl;
- cout<< "Total withdrawn: $"<<totalW<<endl;
- cout<< "Total interest earned: $"<<totalI<<endl;
- cout<< "Final balance: $"<<total<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement