The illustration shows a code segment with an annotation “"The class BankAccount in this program is an improved version of the class BankAccount given in Display 10.6." The lines are numbered from 1 through 41 and the annotations are as follows:
"//Program to demonstrate the recursive member function update (years).
#include <iostream>
using namespace std;
//Class for a bank account:
class BankAccount
{
public:
BankAccount(int dollars, int cents, double rate);
//Initializes the account balance to $dollars.cents and
//initializes the interest rate to rate percent.
BankAccount(int dollars, double rate);
//Initializes the account balance to $dollars.00 and
//initializes the interest rate to rate percent.
BankAccount( );
//Initializes the account balance to $0.00 and
//initializes the interest rate to 0.0%.
void update( );
//Postcondition: One year of simple interest
//has been added to the account balance.
void update(int years);” with the lines "void update()" and void update(int years)" are annotated as "Two different functions with the same name."
“//Postcondition: Interest for the number of years given has been added to the
//account balance. Interest is compounded annually.
double getBalance( );
//Returns the current account balance.
double getRate( );
//Returns the current account interest rate as a percentage.
void output(ostream& outs);
//Precondition: If outs is a file output stream, then outs has already
//been connected to a file.
//Postcondition: Balance & interest rate have been written to the stream outs.
private:
double balance;
double interestRate;
double fraction(double percent); //Converts a percentage to a fraction.
};
int main( )
{
BankAccount yourAccount(100, 5);
yourAccount.update(10);
cout.setf(ios::fixed);"