1. Engineering
  2. Computer Science
  3. i need somone to help me with function headers my...

Question: i need somone to help me with function headers my...

Question details

I need somone to help me with function headers my professor is Off his rocker and keeps saying the programs right but format and function heads are wrong please help

1. All indentation must be correct according to class style guidelines (2 spaces, no tabs, all code blocks correctly indented by level).

2. All functions (and member functions of classes) must have a function header documentation that gives a short description, documents all input parameters using @param tags, and documents the return value if the function returns a value, using @returns tag. You do not have to document class setter/getter methods, but all other class methods should probably be documented

#include
#include
#include
#include
using namespace std;
class RetirementAccount
{

private:
double d, m, r, t;
public:
//Default Constructor
RetirementAccount() {
d = 1.0;
m = 1.0;
r = 1.0;
t = 1.0;
}
RetirementAccount(double d, double m, double r, double t) {
this - > d = d;
this - > m = m;
this - > r = r;
this - > t = t;
}
//setters
void set_D(double d) {
this - > d = d;
}
void set_m(double m) {
this - > m = m;
}
void set_r(double r) {
this - > r = r;
}
void set_t(double t) {
this - > t = t;
}
//getters
double get_D() {
return d;
}
double get_m() {
return m;
}
double get_r() {
return r;
}
double get_t() {
return t;
}
string tostring() {
ostringstream str1, str2, str3, str4;
str1 << d;
str2 << m;
str3 << r;
str4 << t;
return "D (deposit amount) = $ " + str1.str() + " m (periods per year) = " + str2.str() + " r (interest rate) = " + str3.str() + " t (time in years) = " + str4.str() + " ";
}

double calculateRetirementSavings() {
double a = d * (pow(1 + (r / m), (m * t)));
return a;
}
// Sets up the Retirement Deposit equation for later use
double planRetirementDeposits(double s) {
double D = s * (r / m) / (pow((1 + (r / m)), (m * t)) - 1);
return D;
}
};
/* main
* The main entry point for this program.Execution of this program
* will begin with this main function.
** @param argc The command line argument count which is the number of
* command line arguments provided by user when they started
* the program.
* @param argv The command line arguments, an array of character
* arrays.
* @returns An it value indicating program exit status.Usually 0
* is returned to indicate normal exit and a non - zero value
* is returned to indicate an error condition.
* /*/
int main(int argc, char ** argv) {
// test constructor
cout << "=== Testing class creation using constructor..................." << endl << endl;
RetirementAccount account(100.00, 10.0, 0.035, 22.0);

// test getter methods
cout << "=== Testing getter methods..................." << endl;
cout << "Account: " << endl;
cout << " D (deposit amount) = $" << fixed << setprecision(2) << account.get_D() << endl;
cout << " m (periods per year) = " << fixed << setprecision(2) << account.get_m() << endl;
cout << " r (interest rate) = " << fixed << setprecision(4) << account.get_r() << endl;
cout << " t (time in years) = " << fixed << setprecision(2) << account.get_t() << endl;
cout << endl;

// test tostring()
cout << "=== Testing tostring() method..................." << endl;
cout << "Account: " << endl << account.tostring() << endl;
cout << endl;

// test setter methods
cout << "=== Testing setter methods..................." << endl;
account.set_D(500.00);
account.set_m(12.0);
account.set_r(0.048);
account.set_t(25.00);
cout << "Account: " << endl << account.tostring() << endl;

// test retirement savings calculation
cout << "=== Testing retirement savings calculations..................." << endl;
cout << "My retirement savings: $" <<
fixed << setprecision(2) <<
account.calculateRetirementSavings() << endl;
cout << endl;

// test retirement planning calculations
cout << "=== Testing retirement planning calculations..................." << endl;
double newD = account.planRetirementDeposits(1000000.00);
cout << "In order to save 1 million dollars, we need to make monthly deposits of $" <<
fixed << setprecision(2) <<
newD;
cout << endl;
account.set_D(newD);
cout << "If we set our deposit to this new amount..." << endl;
cout << "Account: " << endl << account.tostring() << endl;
cout << "My retirement savings: $" <<
fixed << setprecision(2) <<
account.calculateRetirementSavings() << endl;
cout << endl;

// an additional test of savings and planning calculations
cout << "=== Second test on account2 of savings and planning..................." << endl;
RetirementAccount account2(650.00, 9.0, 0.035, 30.0);
cout << "Account 2:" << endl << account2.tostring() << endl;
cout << "My retirement savings: $" <<
fixed << setprecision(2) <<
account2.calculateRetirementSavings() << endl;
cout << endl;
newD = account2.planRetirementDeposits(2000000.00);
cout << "In order to save 2 million dollars, we need to make deposits of $" <<
fixed << setprecision(2) <<
newD;
cout << endl;
account2.set_D(newD);
cout << "If we set our deposit to this new amount..." << endl;
cout << "Account: " << endl << account2.tostring() << endl;
cout << "My retirement savings: $" <<
fixed << setprecision(2) <<
account2.calculateRetirementSavings() << endl;
cout << endl;

// more tests, demonstrate using arrays of classes and looping over classes
// create 10 RetirementAccount's to perform some comparison calculations
cout << "=== Larger number of tests, compare effect of increasing monthly deposit amount..................." <<
endl;
const int NUM_PLANS = 10;
RetirementAccount plan[NUM_PLANS];

// set all accounts with same interest rate, periods and time, but different
// deposit amounts
double D = 500.00; // base amount to deposit.
double m = 12.0; // make monthly deposits
double r = 0.04; // compound interest rate.
double t = 30.0; // save for retirement for 30 years
for (int i = 0; i < NUM_PLANS; i++) {
plan[i].set_D(D + (i * 100.0));
plan[i].set_m(m);
plan[i].set_r(r);
plan[i].set_t(t);
cout << "Plan " << i << ":" << endl;
cout << plan[i].tostring();
cout << " Total Savings: " <<
fixed << setprecision(2) <<
plan[i].calculateRetirementSavings() << endl;
}
system("pause");
// return 0 to indicate successful completion
return 0;
}

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution