hello all. my task is to write a program that asks the user:
how much money they will save per month
what annual interest rate they hope to earn
how many months to calculate compound interest
what the savings target is (e.g. a million dollars)
my program will then output a month-by-month summary that shows:
how many months the user has been saving money
how much money the user deposited this month (principal)
the total amount of money deposited (principal)
the total amount of money saved (principal and interest)
Once this table of information is printed, your program should print out how many months it took to reach the savings target. If the target is not reached, your program should print out a message like "Sorry, savings target not reached".
now... all that being said, im not asking and i dont want you to write the entire program. (i dont want you to think im "one of those guys").
the issue im trying to figure out is how to add up the total invested for each month.
the second issue i cant figure out is why my collumn "dep this month" is adding up by 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number=1;
//asking the user how much money they will save per month
float save = 1;
do
{
cout<< " How much money will you save/month? ";
cin>> save;
}
while( save <= 0);
//asking the user what interest rate they hope to earn
float interest = 1;
do
{
cout<< " What interest rate do you hope to earn? ";
cin>> interest;
}
while( (interest < 0) || (interest > 100));
//asking the user how many months to calculate compound interest
float months = 1;
do
{
cout<< " How many months do you want to save for ";
cin>> months;
}
while(months <= 0);
//asking the user what the savings target is (e.g. a million dollars)
float target = 1;
do
{
cout<< " What is your savings target? ";
cin>> target;
}
while(target <= 0);
//print out the junk
cout<< setprecision(0) << fixed << "months\tdep.this month\ttotal deposited\ttotal saved\n";
while(number <= months)
{
cout<< number++;
cout<< "\t"<<save;
cout<<"\t"<<save++<<endl;
}
/*Your program will then output a month-by-month summary that shows:
how many months the user has been saving money
how much money the user deposited this month (principal)
the total amount of money deposited (principal)
the total amount of money saved (principal and interest)*/
system("pause");
}
|