C++ Only --Can you help me with my code? I need help showing some of the thing l
ID: 3867688 • Letter: C
Question
C++ Only --Can you help me with my code? I need help showing some of the thing listed in the questions section.
#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;
cout << save << endl;
}
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;
cout << interest << endl;
}
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;
cout << months << endl;
}
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;
cout << target << endl;
}
while(target <= 0);
//print out the junk
cout<< setprecision(0) << fixed << "months dep.this month total deposited total saved ";
while(number <= months)
{
cout<< number++;
cout<< " "<<save;
cout<<" "<<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");
}
Question:
I need code written for a retirement saving plan based off of this algorithm.
For most people, employer pensions, government pensions, and the tax situation in their country are important factors, typically taken account of in calculations by actuaries. Ignoring those significant nation-specific factors but not necessarily assuming zero real interest rates, a "not to be relied upon" calculation of required personal savings rate zprop can be made using a little mathematics.[50] It helps to have a dimly remembered acquaintance with geometric series, maybe in the form
1 + r + r2 + r3 + ... + rn1 = (1 rn)/(1 r)
You work for w years, saving a proportion zprop of pay at the end of each year. So the after-savings purchasing power is (1-zprop) of pay while you are working. You need a pension for p years. Let's say that at retirement you are earning S per year and require to replace a ratio Rrepl of your pre-retirement living standard. So you need a pension of (1 – zprop ) Rrepl S, indexed to price inflation.
Let's assume that the investments, after price inflation fprice, earn a real rate ireal in real terms where
(1+ ireal ) = ((1+inominal))/((1+fprice ) ) (Ret-01)
Let's assume that the investments, after wage inflation fpay, earn a real rate i rel to pay where
(1+ i rel to pay ) = ((1+inominal))/((1+fpay ) ) (Ret-02)
Expectations:
The project will have to require loops, arrays and at least one user-defined function. The final solution should be in the range of 100-200 lines of code.
Explanation / Answer
#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;
cout << save << endl;
}
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;
cout << interest << endl;
}
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;
cout << months << endl;
}
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;
cout << target << endl;
}
while(target <= 0);
//print out the junk
cout<< setprecision(0) << fixed << "months dep.this month total deposited total saved ";
while(number <= months)
{
cout<< number++;
cout<< " "<<save;
cout<<" "<<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");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.