Im trying to make this program into a class rather than a structure as well as making the member variables private. I need to include member functions for each of the following:
1. One to return initial balance
2. One to return balance at maturity
3. One to return interest rate
4. One to return term
I also need to include:
1. A constructor that sets the member variables to any specified values.
2. A default constructor.
3. An input member function with one formal parameter of type istream
4. An output member function with one formal parameter of type ostream.
So far, this is what Ive came up with the code and if I can get help, Id appreciate it. Thanks
CODE
#include <iostream>
double(InitialBalance);
double(BalanceAtMaturity);
double(InterestRate);
int(Term);
//default constructors
InterestRate();
InitialBalance();
BalanceAtMaturity;
Term();
using namespace std;
int main()
{
char dummy;
double balance;
double intRate;
int term;
int CDAccount;
CDAccount account = CDAccount( 100.0, 10.0, 6 );
cout << "CD Account interest rate: "
<< account.InterestRate() << endl;
cout << "CD Account initial balance: "
<< account.InitialBalance() << endl;
cout << "CD Account balance at maturity is: "
<< account.BalanceAtMaturity() << endl;
cout << "CD Account term is: " << account.Term()
<< " months"<< endl;
account.output( cout );
cout << "Enter CD initial balance, interest rate, "
<< " and term:" << endl;
account.input(cin);
cout << "CD Account interest rate: "
<< account.InterestRate() << endl;
cout << "CD Account initial balance: "
<< account.InitialBalance() << endl;
cout << "CD Account balance at maturity is: "
<< account.BalanceAtMaturity() << endl;
cout << "CD Account term is: " << account.Term()
<< " months"<< endl;
account.output( cout );
cout << endl;
cout << "Enter any character and press return to terminate." << endl;
cin >> dummy;
return 0;
}
//with all the member functions, my goal was to make each private but not sure
//on how to do that correctly
//member function
void(double initial_balance);
{
public:
initial_balance()
{
return_initial_balance;
}
private: initial_balance;
};
//member function
void(double maturity_balance);
{
public:
maturity_balance()
{
return_maturity_balance;
}
private: initial_balance;
};
//member function
void(double interest_rate);
{
public:
interest_rate()
{
return_interest_rate;
}
private: interest_rate;
};
//member function
void(int term);
{
public:
term()
{
return_term;
}
private: term;
};