Advertisement
YTTB

Account savings NAR ANE

Feb 5th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.53 KB | None | 0 0
  1. //Dillon Janakus
  2. //Computer Science 1
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <iomanip>
  7. #include <cmath>
  8. #include <fstream>
  9. #include <sstream>
  10.  
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16.     float startB=  0; //Starting balance
  17.     float intRate= 0; //Interest Rate
  18.     float monthsP= 0; //Number of months passed
  19.     float depoM=   0; //Money deposited during each month
  20.     float withM=   0; //Money withdrawn during the month
  21.     float intP=    0; //Interest rate percent
  22.     float totalD=  0; //Total deposited
  23.     float totalI=  0; //Total
  24.     float totalW=  0; //Total withdrawn
  25.     float monthI=  0; //Monthly interest rate
  26.     float total=   0; //Final balance
  27.  
  28.  
  29.     cout << "Enter the starting balance of your account: ";
  30.     cin>>(startB);
  31.  
  32.     while(startB<0)
  33.         {
  34.         cout<< "Negative numbers are not accepted, please try again: ";
  35.         cin>>(startB);
  36.         }
  37.  
  38.     cout<< "Enter the annual interest rate: ";
  39.     cin>>(intRate);
  40.     intP=(intRate/100);
  41.     monthI=(intP/12);
  42.  
  43.     while(intRate<0)
  44.         {
  45.         cout<< "Negative numbers are not accepted, please try again: ";
  46.         cin>>(intRate);
  47.         }
  48.     intP = (intRate/100);
  49.  
  50.     cout<< "Enter the number of months that have passed since the account ";
  51.     cout<< "was established: ";
  52.     cin>>(monthsP);
  53.  
  54.     while(monthsP<0)
  55.         {
  56.         cout<< "Negative numbers are not accepted please try again: ";
  57.         cin>>(monthsP);
  58.         }
  59.     total=startB;
  60.     cout<<endl;
  61.     for(int m=1; m<=monthsP; m++)
  62.         {
  63.         cout<< "Enter the amount of money deposited during month "<<m<<": ";
  64.         cin>> (depoM);
  65.             while(depoM<0)
  66.             {
  67.              cout<< "Negative numbers are not accepted please try again: ";
  68.              cin>>(depoM);
  69.             }
  70.  
  71.             totalD+=depoM;
  72.             total+=depoM;
  73.  
  74.         cout<< "Enter the amount of money withdrawn during month "<<m<<": ";
  75.         cin>> (withM);
  76.             while(withM<0)
  77.             {
  78.              cout<< "Negative numbers are not accepted please try again: ";
  79.              cin>>(withM);
  80.             }
  81.  
  82.             totalW+=withM;
  83.             total-=withM;
  84.            
  85.             totalI+=(total*monthI);
  86.             total+=(total*monthI);
  87.  
  88.         cout<<endl;
  89.         }
  90.  
  91.         cout<< "Total deposited: $"<<totalD<<endl;
  92.         cout<< "Total withdrawn: $"<<totalW<<endl;
  93.         cout<< "Total interest earned: $"<<totalI<<endl;
  94.         cout<< "Final balance: $"<<total<<endl;
  95.  
  96.  
  97.     return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement