#include<iostream>
#include<cmath>
#include<string.h>
using namespace std;
class savingaccount
{
private:
    char id,tl,dre,cop,nam;
    double balance;
    double rate;
    int lastDate;
    double accumulation;
    void record (int date,double amount);//获得到制动日期为止的存款金额按日累计值
    double accumulate(int date) const
    {
        return accumulation+balance*(date-lastDate);
    }
public:
    kaihu(char cd[20],char name[20],char Id[20],char tel[12],char dr[20],char co[20],double Rate,int date)
    {
        cout<<"请输入身份证号:"<<endl;
        cin>>Id;
        cout<<"请输入姓名:"<<endl;
        cin>>name;
        cout<<"请输入电话号码:"<<endl;
        cin>>tel;
        cout<<"请输入地址:"<<endl;
        cin>>dr;
        cout<<"请输入单位地址:"<<endl;
        cin>>co;
    strcpy(id,Id);
    strcpy(nam,name);
    strcpy(tl,tel);
    strcpy(dre,dr);
    strcpy(cop,co);
    balance=0;
    rate=Rate;
    lastDate=date;
    accumulation=0;
    cout<<date<<"\t#"<<id<<"is created!"<<endl;
    }
    char *getId(){return id;}
    char *getnam(){return nam;}
    char *gettl(){return tl;}
    char *getcop(){return cop;}
    char *getdre(){return dre;}
    double getbalance(){return balance;}
    double getrate(){return rate;}
    void deposit (int date,double amount);
    void withdraw(int date,double amount);
    void settle(int date);
    void show();
};
/*savingaccount::savingaccount(int date,char Id[20],double Rate)
{
    strcpy(id,Id);
    balance=0;
    rate=Rate;
    lastDate=date;
    accumulation=0;
    cout<<date<<"\t#"<<id<<"is created!"<<endl;
}*/
void savingaccount::record(int date,double amount)
{
    accumulation=accumulate(date);
    lastDate=date;
    amount=floor(amount*100+0.5)/100;
    balance+=amount;
    cout<<date<<"\t#"<<id<<"\t"<<amount<<"\t"<<balance<<endl;
}
void savingaccount::deposit(int date,double amount)
{
    record(date,amount);
}
void savingaccount::withdraw(int date,double amount)
{
    if (amount>getbalance)
        cout<<"错误!余额不足!"<<endl;
    else
        record(date,-amount);
}
void savingaccount::settle(int date)
{
    double interest=accumulate(date)*rate/365;
    if(interest!=0)
        record(date,interest);
    accumulation=0;
}
void savingaccount::show()
{
    cout<<"#"<<savingaccount::id<<"\tbalance:"<<savingaccount::balance<<endl;
}
void main()
{
    int s;
    cout<<"********************"<<"欢迎进入银行系统!"<<"*******************"<<endl;
    cout<<"***************"<<"请选择您要进入的系统服务序号:"<<"***************"<<endl;
python中字符串是什么
    cout<<"*******"<<"1开户系统"<<"*******"<<endl;
    cout<<"********"<<"2存款业务"<<"********"<<endl;
    cout<<"*********"<<"3取款业务"<<"********"<<endl;
    cout<<"**********"<<"4查询业务"<<"**********"<<endl;
    cin>>s;
    switch(s)
    {
    case 1:savingaccount::kaihu();
        break;
    case 2:savingaccount::deposit();
        break;
    case 3:savingaccount::withdraw();
        break;
    case 4:savingaccount::show();
        break;
    }
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。