# include
using namespace std;
The class SavingsAccount {
Private:
int id;//account
Double balance;//the balance
Double rate;//deposit interest rate
Double accumulation;//balance daily accumulation and
Int lastdate;//the last calculation time
p.a.Double the accumulate (int the date)
Const {
Return accumulation + balance * (the date - lastdate);
}
Void record (int the date, double the amount);//record a bill, the date the date, amount amount
Public:
SavingsAccount (int the date, int id, int rate);
Int getid () {return id; }
Double the getbalance () {return the balance; }
Double getrate () {return rate; }
Void the show ();//show the account information
Void deposit (int the date, double the amount);//show the deposit amount
Void withdraw (int the date, double the amount);//show the amount
Void settle (int the date);//clearing annual interest
};
//SavingsAmount related member function implementation of
SavingsAccount: : SavingsAccount (int the date, int id, int rate)
{
Id=id;
The balance=0;
Rate=rate;
Lastdate=date;
Accumulation=0;
Cout
void SavingsAccount: : record (int the date, double the amount)//billing
{
Accumulation=the accumulate (date);
Lastdate=date;
Amount=floor (amount * 100 + 0.5)/100; //the red of this paragraph, amount=floor (amount * 100 + 0.5)/100; What's the meaning of ah
The balance +=amount;
Cout<& lt;" Error: not enough money "& lt;
Void SavingsAccount: : deposit (int the date, double the amount)//deposit amount
{
Record (the date and amount);
}
Void SavingsAccount: : withdraw (int the date, double the amount)//withdrawal amount
{
If (amount> The getbalance ())
Cout<& lt;" Error: not enough money "& lt;
Record (the date and amount);
}
Void SavingsAccount: : settle (int the date)//settlement interest
{
Double interest=the accumulate (date) * rate/365;
//the calculation of the p.a.=account balance daily accumulation and/365 days * at an annual rate
If (interest!=0)
Record (date, interest);
Accumulation=0;//after each calculation, will accumulate and reset, starting from the current balance of accumulative
}
Void SavingsAccount: : show ()//show the account information
{
Cout<& lt;" # "& lt;
Int main ()
{
//define the object, the establishment of a few accounts
38,0.015 SavingsAccount save1 (1121);
48,0.015 SavingsAccount save2 (1121);
//the function member, a few account
Save1. Deposit (5500);
Save2. Deposit (25100, 00);
Save1. Deposit (45550);
Save2. Withdraw (60400);
//calculate annual interest
Save1. Settle (90);
Save2. Settle (90);
//output each account information
Save1. The show ();
Save2. The show ();
return 0;
}