⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bank2.cpp

📁 有两个账户供选择
💻 CPP
字号:
#include <iostream.h>
#include "Savings.h"
#include "Checkings.h"
#include "Account.h"
#include "fstream.h"
void main()
{
	unsigned a[100];
	int k=0,v,t=0;
label:
	int i;
  	cout<<"             欢迎进入银行账户系统             "<<endl; 
	cout<<"*"<<"---------------------------------------------"<<"*"<<endl;
	cout<<"|"<<"  1. 开          户   "<<"|"<<"  2. 储   蓄  存  款  "<<"|"<<endl;
	cout<<"|"<<"  3. 储  蓄  取  款   "<<"|"<<"  4. 结   算  存  款  "<<"|"<<endl;
	cout<<"|"<<"  5. 结  算  取  款   "<<"|"<<"  6. 查 找 储 蓄 账户 "<<"|"<<endl;
	cout<<"|"<<"  7. 查 找 结 算 帐户 "<<"|"<<"  8. 显示所有储蓄账户 "<<"|"<<endl;
	cout<<"|"<<"  9. 显示所有结算账户 "<<"|"<<" 10. 删 除 所 有 账户 "<<"|"<<endl;
	cout<<"|"<<" 11. 查看所有账户总数 "<<"|"<<" 12. 退            出 "<<"|"<<endl;
    cout<<"*"<<"---------------------------------------------"<<"*"<<endl;
	cout<<"请选择操作(键入数字1-5):";
    cin>>i;
	switch(i)
	{
	case 1://开户
		{   
			int j;
			cout<<"请输入要开户的类型(1.储蓄账户 2.结算账户):";
            cin>>j;
			switch(j)
			{
			case 1:
				{
                    Savings* pS;//储蓄账户开户
                    unsigned aN;
                 save:
                    cout<<"请输入储蓄账号(形式为1xx,以0结束):"<<endl;              
                    cin>>aN;
					if(aN==0) 
					{
						cout<<"输入结束"<<endl;
						 cout<<endl;
						goto end1;
					}
					for(v=0;v<100;v++)
					{
						if(aN==a[v])
						{
						   cout<<"此帐号已存在,请尝试其他帐号"<<endl;
						    cout<<endl;
						   goto save;
						}
					}
					
					if((aN/10)>19||(aN/10)<10)
					{
						cout<<"输入错误"<<endl;
						 cout<<endl;
					    goto save;
					}
					else
					{a[k]=aN;
					cout<<"您的账号为"<<a[k]<<endl;
					k++;
                     while(aN)
						{
                           
                         save1:
						   pS=new Savings(aN);
                           cout<<"请输入储蓄账号(形式为1xx,以0结束):"<<endl;
                           cin>>aN;
						   if(aN==0) 
						   {
							   cout<<"输入结束"<<endl;
							    cout<<endl;
							   goto end1;
						   }
						   for(v=0;v<100;v++)
						   {
						      if(aN==a[v])
							  {
						         cout<<"此帐号已存在,请尝试其他帐号"<<endl;
								 cout<<endl;
						         goto save1;
							  }
						   }
					       a[k]=aN;
					       k++;
						   if((aN/10)>19||(aN/10)<10)
						   {
							
						       cout<<"输入错误"<<endl;
							    cout<<endl;
					           goto save1;
						   }
						}
					}
				};break;
			case 2:
				{

                    Checkings* pC;//结算账户开户 
			        unsigned aN;
                check: 
                    cout<<"请输入结算账号(形式为2xx,以0结束):"<<endl;
                    cin>>aN;
					if(aN==0) 
					{
						cout<<"输入结束"<<endl;
						 cout<<endl;
						goto end1;
					}
					for(v=0;v<100;v++)
						   {
						      if(aN==a[v])
							  {
						         cout<<"此帐号已存在,请尝试其他帐号"<<endl;
								  cout<<endl;
						         goto check;
							  }
						   }
					       					
					if((aN/10)>29||(aN/10)<20)
					{
						cout<<"输入错误"<<endl;
						 cout<<endl;
					    goto check;
					}
					else
					{a[k]=aN;
					cout<<"您的账号为"<<a[k]<<endl;
					k++;
                    
                        while(aN)
						{
                        check1:
                            pC=new Checkings(aN);
                            cout<<"请输入结算账号(形式为2xx,以0结束):"<<endl;
                            cin>>aN;
							if(aN==0) 
							{
								cout<<"输入结束"<<endl;
								 cout<<endl;
								goto end1;
							}
							for(v=0;v<100;v++)
							{
						      if(aN==a[v])
							  {
						         cout<<"此帐号已存在,请尝试其他帐号"<<endl;
								  cout<<endl;
						         goto check1;
							  }
						   }
					       a[k]=aN;
					       k++;
							if((aN/10)>29||(aN/10)<20)
							{
						        cout<<"输入错误"<<endl;
								 cout<<endl;
					            goto check1;
							}
						}
					}
				};break;
			default:cout<<"输入错误"<<endl;break;
			}
        end1:
			cout<<"操作完毕"<<endl;
			 cout<<endl;
		};break;

	case 2://存款
		{
			Savings* pS;
			unsigned aN;
			double earmark;
			cout<<"请输入帐号(形式为1xx):";
			cin>>aN;
		    if((aN/10)>19||(aN/10)<10)
			{
				cout<<"输入错误"<<endl;
				 cout<<endl;
			    goto save;
			}
			else
			{
		        for(Savings* p=(Savings*)pS->getFirst(); p ;p=(Savings*)p->getNext())
				{
				    if(aN==p->AccountNo())
					{
			           cout<<"请输入要存入的资金:";
			           cin>>earmark;
				       p->Deposit(earmark);
				       goto sin;
					}
				}
			}
        sin:
		   cout<<"操作完毕"<<endl;   
		    cout<<endl;
		};break;
	case 3:
		{
            Savings* pS;
			unsigned aN;
			double outmark;
			cout<<"请输入帐号(形式为1xx):";
			cin>>aN;
			if((aN/10)>19||(aN/10)<10)
			{
				cout<<"输入错误"<<endl;
				 cout<<endl;
			    goto save;
			}
			else
			{
                 for(Savings* p=(Savings*)pS->getFirst(); p ;p=(Savings*)p->getNext())
				 {
				      if(aN==p->AccountNo())
					  {
			              cout<<"请输入要取出的资金(可透支5000元):";
				          cin>>outmark;
				          p->Withdrawal(outmark);
				          goto sout;
					  }
				 }
			}
        sout:
			cout<<"操作完毕"<<endl;
			 cout<<endl;
		};break;
	case 4:
		{
			Checkings* pC;
			unsigned aN;
			double earmark;
			cout<<"请输入帐号(形式为2xx):";
			cin>>aN;
			if((aN/10)>29||(aN/10)<20)
			{
				cout<<"输入错误"<<endl;
				 cout<<endl;
			    goto save;
			}
			else
			{
			    for(Checkings* p=(Checkings*)pC->getFirst(); p ;p=(Checkings*)p->getNext())
				{
				   if(aN==p->AccountNo())
				   {
			           cout<<"请输入要存入的资金:";
			           cin>>earmark;
				       p->Deposit(earmark);
				       goto cin;
				   }
				}
			}
        cin:
			cout<<"操作完毕"<<endl;
			 cout<<endl;
		};break;
	case 5:
		{
			Checkings* pC;
			unsigned aN;
			double outmark;
			int i;
			cout<<"请输入帐号(形式为2xx):";
			cin>>aN;
			if((aN/10)>29||(aN/10)<20)
			{
				cout<<"输入错误"<<endl;
				 cout<<endl;
			    goto save;
			}
			else
			{
			    for(Checkings* p=(Checkings*)pC->getFirst(); p ;p=(Checkings*)p->getNext())
				{
				   if(aN==p->AccountNo())
				   {
			          cout<<"请输入要取出的资金:";
			          cin>>outmark;
					   cout<<endl;
				      cout<<"请输入取款的方式(1.电汇 2.信汇 3.其他):";
				      cin>>i;
				      switch(i)
					  {
				         case 1:{p->SetRemit(remitCable);p->Withdrawal(outmark);};break;
				         case 2:{p->SetRemit(remitPost);p->Withdrawal(outmark);};break;
				         case 3:{p->SetRemit(remitother);p->Withdrawal(outmark);};break;
                         default:cout<<"输入错误"<<endl;break;
					  }
				      goto cout;
				   }
				}
			}
        cout:
			cout<<"操作完毕"<<endl;
			 cout<<endl;
		};break;
	case 6:
		{
         save2:
			Savings* pS;
			unsigned aN;
			cout<<"请输入帐号(形式为1xx):";
			cin>>aN;
			if((aN/10)>19||(aN/10)<10)
			{
				cout<<"输入错误"<<endl;
				 cout<<endl;
			    goto save2;
			}
			else
			{
                 for(Savings* p=(Savings*)pS->getFirst(); p ;p=(Savings*)p->getNext())
				 {
				      if(aN==p->AccountNo())
					  {
			              cout<<"要查找的资料为:"<<endl;
				          p->Display();
						  cout<<endl;
				          goto sask;
					  }
				 }
			}
        sask:
			cout<<"操作完毕"<<endl;
			 cout<<endl;
		};break;
    case 7:
		{
         check2:
			Checkings* pC;
			unsigned aN;
			cout<<"请输入帐号(形式为2xx):";
			cin>>aN;
			if((aN/10)>29||(aN/10)<20)
			{
				cout<<"输入错误"<<endl;
				 cout<<endl;
			    goto check2;
			}
			else
			{
			    for(Checkings* p=(Checkings*)pC->getFirst(); p ;p=(Checkings*)p->getNext())
				{
				   if(aN==p->AccountNo())
				   {
			          cout<<"要查找的资料为:"<<endl;
				      p->Display();
					   cout<<endl;
				      goto cask;
				   }
				}
			}
        cask:
			cout<<"操作完毕"<<endl;
			 cout<<endl;
		};break;
	case 8:
		{
			Savings* pS;
			for(Savings* p=(Savings*)pS->getFirst(); p; p=(Savings*)p->getNext())
			{
				if(p->AccountNo()/100==1)
                   p->Display();
			}
		};break;
	case 9:
		{
			Checkings* pC;
			for(Checkings* p=(Checkings*)pC->getFirst(); p; p=(Checkings*)p->getNext())
            {
				if(p->AccountNo()/100==2)
				   p->Display();
			}
		};break;
	case 10:
		{
            Savings *pS;
			int j;
			for(Savings *p=(Savings*)pS->getFirst(); p ;)
			{
            
				   Savings* t=p;
                   p=(Savings*)p->getNext();
                   delete t;
		}
        pS->getFirst()=NULL;
		pS->NoAccounts()=0;
		for(j=0;j<100;j++)
		{
	      a[j]=0;
		}
        cout<<"已全部清除!"<<endl;
		cout<<"操作完毕!"<<endl;
		cout<<endl;
		};break;
	case 11:
		Savings *p;
		cout<<endl;
		cout<<"账户总数为:"<<p->NoAccounts()<<endl;
		cout<<endl;break;
    case 12:
	Account* p1;
	ofstream fout("c:\\zh.txt");
	for(p1=Account::getFirst();p1;p1=p1->getNext())
	{
		fout<<"账号:"<<p1->AccountNo()<<endl;
        
		fout<<"余额:"<<p1->GetBalance()<<endl;
		fout<<endl;
	}
	return;break;
	
 }
 goto label;
}
		


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -