📄 term.cpp
字号:
#include<iostream.h>
#include"account.h"
#include"term.h"
TermAccount::TermAccount(unsigned accNo,float balan)
:Account(accNo,balan)
{
type=4;
int t;
cout<<"请您选择存储期限?"<<endl
<<"1.一年 2.三年 3.五年 ? ";
cin >>t;
if (t==1)
term=OneYear;
else{
if(t==2)
term=ThreeYear;
else
term=FiveYear;
}
maturity_sign=1; //省略日期判断
//0表示还没有到期,1表示到期
}
void GotMoney(double a,float& balance) //取出全部存款
{
cout<<"您的本金和利息: "<<a<<endl;
balance=0;
}
void TermAccount::Withdrawal(float)
{
time_to_now=4; //简化日期程序,
//4表示存款到现在的年数
double temp;char i;
if(maturity_sign==0){ //判断是否到期
cout<<"您的定期帐号还没有到期."<<endl
<<"确定继续吗? ";
cin >>i;
if (i=='y'||i=='Y'){
temp=balance;
for(int j=0;j<time_to_now;j++)temp=temp*(1+0.01);
GotMoney(temp,balance);
return;
}
else
return;
}
if(term==OneYear) //按存款时间取出本金和利息
temp=balance*(1+0.05);
else if(term==ThreeYear)
temp=balance*(1+0.08)*(1+0.08)*(1+0.08);
else
temp=balance*1.1*1.1*1.1*1.1*1.1;
GotMoney(temp,balance);
}
void TermAccount::Display()
{
cout<<"帐号:"<<acntNumber<<" = "
<<balance<<endl
<<"帐户类型为 \"定期存款\"."<<endl;
}
void TermAccount::Deposit(float amount)
{
if(maturity_sign==0){
cout<<"这不是一个定期帐户."<<endl
<<"您不能在到期以前存款."
<<endl;
return;
}
else
balance+=amount;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -