This is the program code that I need to modify from. I have it correct from the
ID: 3627574 • Letter: T
Question
This is the program code that I need to modify from. I have it correct from the previous step. So, not much should be changed, just need to write that new function that returns...Here is my code:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int option1(int age)
{
int retire, left;
if (age >= 60)
retire = 65;
if ( (age >= 50) && (age < 60) )
retire = 67;
if ( (age >= 40) && (age < 50) )
retire = 70;
if (age < 40)
retire = 72;
left = retire - age;
return left;
cout << "You have " << left << " years until retirement." << endl;
}
int main()
{
string name;
int age, week, salary, percent, option = 0;
double rate, investment, n, pmt, wr;
cout << "What is your name? ";
getline(cin, name) ;
cout << "How old are you? ";
cin >> age;
do
{
cout << "Please select an option: " << endl;
cout << " (1) Number of years to retirement" << endl;
cout << " (2) Amount earned between now and retirement" << endl;
cout << " (3) Amount saved at retirement" << endl;
cout << " (4) Exit (do nothing)" << endl;
cin >> option;
switch (option)
{
case 1:
cout << "You have " << option1(age) << " years until retirement." << endl;
break;
case 2:
cout << "How much do you make per week in dollars? ";
cin >> week;
salary = week * 52 * ( option1(age) );
cout << "You will earn $";
cout << salary << " between now and retirement.";
cout << endl;
cout << endl;
break;
case 3:
cout << "How much do you make per week in dollars? ";
cin >> week;
cout << "What percentage will you save? ";
cin >> percent;
cout << "There are ";
cout << option1(age) << " years till retirement." << endl;
{ wr = .06 / 52;
rate = percent / 100.0;
pmt = (week * rate);
cout << "pmt is " << pmt << endl;
cout << "wr is " << wr << endl;
n = ( option1(age) ) * 52;
cout << "n is " << n << endl;
investment = ((pow((1 + wr), n) - 1) * pmt) / wr;
}
cout << "You will have $" << investment << " saved when you retire." << endl;
cout << endl;
cout << endl;
break;
case 4:
break;
default:
cout << "Please choose a valid option.";
cout << endl;
cout << endl;
break;
}
}
while (option != 4);
cout << endl;
cout << "Thanks for using our program!";
cout << endl;
}
Explanation / Answer
DEAR FRIEND this the program and added the function u want PLEASE RATE #include #include #include using namespace std; int weeklySalary (int week) { cout > week; return week; } int option1(int age) { int retire, left; if (age >= 60) retire = 65; if ( (age >= 50) && (age < 60) ) retire = 67; if ( (age >= 40) && (age < 50) ) retire = 70; if (age < 40) retire = 72; left = retire - age; return left; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.