#include<iostream>
using namespace std;
int main()
{
bool codes();
void work();
cout<<"歡迎使用ATM"<<endl;
cout<<"請輸入6位數密碼:";
if(codes())
work();
else
cout<<"對不起,由於你的密碼三次輸入錯誤,系統已將你的卡鎖定,請拿著相關證件到營業廳解鎖"<<endl;
return 0;
}
bool codes()
{
bool code=false;
int mima,num=1;
do
{
if(num>1)
cout<<"(提示:這是第"<<num<<"次輸入密碼,三次不對你的卡將被鎖定!)"<<endl<<"請再次輸入密碼:";
cin>>mima;
num++;
if(mima==654321)
code=true;
}
while(!code&&num<=3);
return code;
}
void work()
{
char choice;
bool exit = false;
do
{
void showbalance();
void drawmoney();
void deposit();
void transferAccounts();
cout<<endl<<"* 您可以辦理下面的業務:"<<endl;
cout<<"* 1.查詢"<<endl;
cout<<"* 2.取款"<<endl;
cout<<"* 3.存款"<<endl;
cout<<"* 4.轉賬"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 請輸入(0-4):";
cin>>choice;
switch(choice)
{
case '1':
showbalance();
break;
case '2':
drawmoney();
break;
case '3':
deposit();
break;
case '4':
transferAccounts();
break;
case '0':
cout<<"歡迎再次使用!"<<endl;
exit=true;
}
}while(!exit);
return;
}
void showbalance()
{
cout<<"您的余額為****"<<endl;
}
void drawmoney()
{
double money;
cout<<"請輸入取款金額:";
cin>>money;
cout<<" 對不起,您的余額已不足!";
}
void deposit()
{
int type, days;
double moneys, period, rate, interest;
cout<<"請輸入存款金額:";
cin>>moneys;
cout<<"======存款期限======"<<endl;
cout<<"1. 活期存款"<<endl;
cout<<"2. 3個月"<<endl;
cout<<"3. 6個月"<<endl;
cout<<"4. 一年 "<<endl;
cout<<"5. 二年"<<endl;
cout<<"6. 三年"<<endl;
cout<<"7. 五年"<<endl;
cout<<"請輸入存款期限的代號:";
cin>>type;
if (type>=1 && type<=7)
{
switch(type)
{
case 1:
cout<<"請輸入存款天數:";
cin>>days;
period=days/360.0;
rate=0.005;
break;
case 2:
period=0.25;
rate=0.031;
break;
case 3:
period=0.5;
rate=0.033;
break;
case 4:
period=1;
rate=0.035;
break;
case 5:
period=2;
rate=0.044;
break;
case 6:
period=3;
rate=0.05;
break;
case 7:
period=5;
rate=0.055;
break;
}
interest=moneys*period*rate;
cout<<"到期利息為:"<<interest<<"元,本息合計共"<<interest+moneys<<"元。"<<endl;
}
else
cout<<"選擇存款類型錯誤!"<<endl;
cout<<"感謝您的使用,歡迎下次光臨!"<<endl;
}
void transferAccounts()
{
long int number;
int money;
cout<<"請輸入轉賬的卡號:";
cin>>number;
cout<<"請輸入轉賬金額:";
cin>>money;
cout<<"對不起,您的余額已不足!"<<endl;
}