随风1202 2014-12-30 05:45 采纳率: 0%
浏览 2069

求大神指点!!交作业急,C++银行管理系统,运行总是停止工作,是哪个代码不对吗?

#include
#include
#include
#include
using namespace std;
class Count
{
private:
int zhanghao;
string name;
int idcard;
string password;
double money;
string address;
int phone;
string condition;
public:
friend class bank;
Count(int zh,string n,int id,string passw,double m,string ad,int p,string zt)
{
zhanghao=zh;
name=n;
id=idcard;
password=passw;
money=m;
address=ad;
phone=p;
condition=zt;
}
Count()
{
zhanghao=' ';
name=' ';
idcard=' ';
password=' ';
money=' ';
address=' ';
phone=' ';
condition=' ';
}
int get_zhanghao()
{return zhanghao;}
string get_name()
{return name;}
int get_id()
{return idcard;}
double get_money()
{return money;}
string get_ad()
{return address;}
string get_passw()
{return password;}
void display();
};

class bank
{
private:
int i;
protected:
Count * account[1000];
static int ac_number;
public:
bank()
{
for(i=0;i<1000;i++)
account[i]=NULL;
}
void menu();
void enter();
void functionshow();
void set_count();
void close_count();
void savemoney();
void getmoney();
void transfer();
void query_count();
void query_id();
time_t Time();
void savefile();
void loadfile();
};

int bank::ac_number =0;
time_t bank::Time()
{
struct tm local;
time_t t;
t=time(&t);
//printf("%s", ctime(&t));
//t=time();
tm *T=gmtime(&t);
int year=T->tm_year+1900;
int month=T->tm_mon+1;
int day=T->tm_mday;
int hour=T->tm_hour+8;
int min=T->tm_min;
int sec=T->tm_sec;
cout< cout ofstream ofile("bank.txt",ios::app);
ofstream outfile("bank.txt",ios::app);
outfile outfile outfile outfile outfile outfile cout return 0;
}
void bank::set_count()
{
string nam,addr,key,st,i;
int id,pho,mone;
int n=0;
string C="开户";
if(ac_number {
n=ac_number+1;
cout }
cout cout cin>>nam;
cout<<"IDcard:";
cin>>id;
cout<<"Phone:";
cin>>pho;
cout<<"Address:";

cin>>addr;
cout<<"Please set the password:";
cin>>key;
cout<<"Please the number money:";
cin>>mone;
st="normal";
Count *pointer=new Count(n,nam,id,key,mone,addr,pho,st);
account[ac_number]=pointer;
ac_number++;
cout<<"开户成功!!"< bank::Time();
ofstream ofile("bank.txt",ios::app);
ofstream outfile("bank.txt",ios::app);
outfile outfile outfile bank::savefile ();
cin>>i;
system("cls");
menu();
}
void bank::close_count()
{
int zh,n,r=1;
n=0;
string C="销户";
string passw;
cout<<"Please enter account number:";
cin>>zh;
if(zh==(account[n]->get_zhanghao()))
{
cout<<"please enter password:";
cin>>passw;
if(passw==(account[n]->get_passw()))
{
account[n]->display();
cout<<"Do you really want to close this account?(1-yes,2-no)"< cin>>r;
if(r==1)
{
account[n]->condition="Close";
account[n]->money='0';
cout << endl<<"The account have already close!" << endl;
}
else
close_count();
}
else
{
cout<<"ERROR!"< return ;
}
}
else
{
cout return;
}
Time();
ofstream ofile("bank.txt",ios::app);
ofstream outfile("bank.txt",ios::app);
outfile outfile outfile savefile();
}
void bank::transfer()
{
int zh,md;
double m;
string C="转账";
int n=0;
cout cin>>zh;
for(n;n {
if(zh==(account[n]->get_zhanghao()))
{
cout<<"enter the number of money:";
cin>>m;
if(m<=(account[n]->get_money()))
{
cout<<"please enter the account number:";
cin>>md;
getmoney();
Time();
ofstream ofile("bank.txt",ios::app);
ofstream outfile("bank.txt",ios::app);
outfile< outfile outfile outfile savefile();
}
else
{
cout return;
}
}
}
}
void bank::savemoney()
{
int n;
double m;
string i;
string C="存款";
n=ac_number;
cout cin>>m;
account[n]->money=account[n]->money+m;
bank::Time();
ofstream ofile("bank.txt",ios::app);
ofstream outfile("bank.txt",ios::app);
outfile< outfile outfile outfile bank::savefile();
cin>>i;
system("cls");
functionshow();
}
void bank::getmoney()
{
double m;
int n;
string C="取款";
//n=ac_number;
cout<<"please enter th emoney you want get:";
cin>>m;
account[n]->money=account[n]->money-m;
bank::Time();
ofstream ofile("bank.txt",ios::app);
ofstream outfile("bank.txt",ios::app);
outfile<<endl;
outfile<<n<<" ";
outfile<<C<<" ";
outfile<<m<<" ";
bank::savefile();
}
void Count::display()
{
cout<<" *
Name:"< cout cout cout cout cout }
void bank::savefile()
{
ofstream ofile("Count.txt",ios::out);
ofstream outfile("Count.txt",ios::out);
int n=0;
outfile for(;n {
outfilezhanghao<<" ";
outfile<name<<" ";
outfile<idcard<<" ";
outfile<phone<<" ";
outfile<address<<" ";
outfile<money<<" ";
outfile<password<<" ";
outfile<condition<<" ";
}
outfile.close();
}
void bank::loadfile()
{
ifstream infile("Count.txt",ios::in);
if(!infile)
{
cerr<<"读取错误"< return;
}
int n=0;
int zh,id,pho;
string nam,passw,addre,c;
double m;
infile>>ac_number;
for(;n {
infile>>zh;
infile>>nam;
infile>>id;
infile>>pho;
infile>>addre;
infile>>m;
infile>>passw;
infile>>c;
account[n]->password;
Count *pointer=new Count(zh,nam,id,passw,m,addre,pho,c);
account[n]=pointer;
cout<<endl;
}
infile.close();
cout<<"读取资料正常!"<<endl;
}

void bank::enter()
{
int zh,i=1;
string passw;
cout<<"please enter the account number:";
cin>>zh;
for(i=1;i<=1000;i++)
{
if(zh==(account[i]->get_zhanghao()))
{
cout<<"please enter password:";
cin>>passw;
if(passw==(account[i]->get_passw()))
bank::functionshow();
else
{
cout<<"ERROR! Please try again!"< enter();
}
}
else
{
cout enter();
}
}
}
void bank::menu()
{
loadfile();
cout cout cout cout cout int m,n,flag;
cout cin>>n;
if(n>=1&&n<=3)
flag=1;
else
{
flag=0;
cout<<"输入有误!";
}
while(flag==1)
{
switch(n)
{
case 1:cout<<"*****开户*****\n";
this->set_count();
break;
case 2:cout<<"*****销户*****\n";
this->close_count();
break;
case 3:cout<<"*****用户基本操作*****\n";
this->enter();
break;
case 4:
break;
default:
break;
}
//getchar();
cout<<"\n";
cout<<"是否继续进行(y or n):\n";
cin>>m;
if(m==1)
{
system("cls");
this->menu();
cout<<"请再次选择你所需要的操作:\n";
cin>>n;
cout<<"\n";
}
else
return ;
}
}
void bank::functionshow()
{
int m,n,flag;
cout<<"1.存款\n";
cout<<"2.取款\n";
cout<<"3.转账\n";
cout<<"4.查看基本信息\n";
cout<<"请选择你需要的步骤:\n";
cin>>n;
if(n>=1&&n<=4)
flag=1;
else
{
flag=0;
cout<<"输入有误!";
}
while(flag==1)
{
switch(n)
{
case 1:cout<<"*****存款*****\n";
this->savemoney();
break;
case 2:cout<<"*****取款*****\n";
this->getmoney();
break;
case 3:cout<<"*****转账*****\n";
this->transfer();
break;
case 4:cout<<"*****查看基本信息*****\n";
account[n]->display();
break;
case 5:
break;
default:
break;
}
//getchar();
cout<<"\n";
cout<<"是否继续进行(y or n):\n";
cin>>m;
if(m==1)
{
system("cls");
this->functionshow();
cout<<"请再次选择你所需要的操作:\n";
cin>>n;
cout<<"\n";
}
else
return ;
}
}
int main()
{
int n=0;
bank account[1000];
account[n].menu();
system("pause");
return 0;
}

  • 写回答

1条回答 默认 最新

  • 杨小兵 2015-01-03 03:48
    关注

    大哥,你的代码咩有太大的问题,可能是你不是很了解流程,去问一下给你程序的人,问清楚业务逻辑,倒是后按照要求输入,不会有很大的问题,应该是你的输入格式不是很对

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog