The illustration shows a code segment with the lines numbered from 24 through 65 and the annotations are as follows:
"Postcondition: One year of simple interest has been added
//to the account balance.
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: Account balance and interest rate
//have been written to the stream outs.
private:
double balance;
double interestRate;
double fraction(double percent);
//Converts a percentage to a fraction. For example, fraction(50.3)
//returns 0.503.
};
int main( )
{"
"BankAccount account1(100, 2.3), account2;" with “account2” annotated as "This declaration causes a call to the default constructor. Notice that there are no parentheses."
"cout << "account1 initialized as follows:\n";
account1.output(cout);
cout << "account2 initialized as follows:\n";
account2.output(cout);"
"account1 = BankAccount(999, 99, 5.5);" annotated as "An explicit call to the constructor BankAccount::BankAccount."
"cout << "account1 reset to the following:\n";
account1.output(cout);
return 0;
}
BankAccount::BankAccount(int dollars, int cents, double rate)
{
if ((dollars < 0) || (cents < 0) || (rate < 0))
{
cout << "Illegal values for money or interest rate.\n";
return;
}
balance = dollars + 0.01 * cents;
interestRate = rate;
}
BankAccount::BankAccount(int dollars, double rate)
{"