程序有错,能否帮我在原有的基础上修改一番,谢谢
#include <iostream>#include <string>
using namespace std;
class Bank
{
public:
Bank(string na,int nu,float ba,float de,float wi)
{name=na; number=nu; balance=ba; deposit=de; withdraw=wi;
}
void display1(); //输入账户基本信息,名字,账户号,本金,存款,取款
protected:
string name;
int number;
float balance;
float deposit;
float withdraw;
};
void Bank::display1()
{
cout<<"name:"<<name<<endl;
cout<<"number:"<<number<<endl;
cout<<"balance:"<<balance<<endl;
cout<<"deposit:"<<deposit<<endl;
cout<<"withdraw:"<<withdraw<<endl;
}
class Checking:public Bank //此类增添两个数据,
//该类需要重写提款功能,操作时需要判断balance是否足够,然后再进行提款,提取后查看balance是否低于minimum, 以便决定是否收取月费。
{public:
Checking(string na,int nu,float ba,float de,float wi,float mi,float ch):Bank(na,nu,ba,de,wi)
{ minimum=mi; charge=ch;
}
void charge1() //保留一定的金额minimum,如果balance少于此金额,就要收取一定的月费charge
{
de=de-wi;
if(de<minimum)
{
charge=de*0.03;
}
}
private:
float minimum;
float charge;
};
class Saving:public Bank //此类增添一个数据,计算出账户每个月挣的利息,累加进balance内。
{
public:
Saving(string na,int nu,float ba,float de,float wi,float in):Bank(na,nu,ba,de,wi)
{
intrate=in;
}
void intrate1()
{
int n;
cout<<"number month:"<<n<<endl;
in=(de*0.1)/(n*100);
}
private:
float intrate;
};
int fun1(char A)
{
char choice; //用户选择A,进入的二级菜单
cout<<"The Second Menu:"<<endl;
cout<<"[C] Add a checking account: [D] Add a Saving account:"<<endl;
cout<<" [Q] Quit:"<<endl;
cin>>choice;
while(getchar()!='\n') continue;
switch(choice)
{case 'C':
break;
case 'D':
break;
case 'Q':
return 0;
}
void fun2(char S)
{
Bank t2;
cout<<"please input you need show account's number:"<<endl;
int x;
if(x==t2.number)
{
cout<<"name:"<<t2.name<<endl;
cout<<"number:"<<t2.number<<endl;
cout<<"balance:"<<t2.balance<<endl;
cout<<"deposit:"<<t2.deposit<<endl;
cout<<"withdraw:"<<t2.withdraw<<endl;
cout<<"funds"<<t2.funds<<endl;
}
}
void fun3(char N)
{
Bank t3;
cout<<"please account's number:"<<endl;
int n;
if(n==t3.number)
{
cout<<"funds:"<<t3.funds<<endl;
}
}
int main()
{
int i;
char showmenu();
Bank a[3]; //输入三个人的信息
Checking b[3];
Saving c[3];
for(i=0;i<3;i++)
{
a[i].display1;
b[3].charge1;
c[3].intrate1;
}
char choice;
while(1)
{
cout<<"MENU BAR:"<<endl;
cout<<"[A] Add an account: [S] Show account:"<<endl;
cout<<"[N] Number of account: [Q] Quit:"<<endl;
cout<<"[R] Return menu: [F] Save accounts to files //暂时不用完成此功能"<<endl;
cin>>choice; //如果用户选择A, 进入二级菜单如下:[C] Add a checking account [S] Add a Saving account [Q] Quit operation
while(getchar()!='\n') continue;
switch(choice)
{case 'A':
fun1(choice); break;
case 'S':
fun2(choice); break;
case 'N':
fun3(choice); break;
case 'F':
break;
case 'R':
break;
case 'Q':
return 0;
}
}
return 0;
}