| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 577 人关注过本帖
标题:程序有错,能否帮我在原有的基础上修改一番,谢谢
只看楼主 加入收藏
Vsnow
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:124
专家分:145
注 册:2015-1-3
结帖率:95%
收藏
已结贴  问题点数:30 回复次数:1 
程序有错,能否帮我在原有的基础上修改一番,谢谢
#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;
}
搜索更多相关主题的帖子: number public include deposit balance balance deposit include public number 
2015-06-03 10:29
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:30 
程序代码:
#include <iostream>
#include <string>
using namespace std;
class Bank
{
public:
    Bank(){
    }
    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(){
    }
    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(float de,float wi){    //保留一定的金额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(){
    }
    Saving(string na,int nu,float ba,float de,float wi,float in):Bank(na,nu,ba,de,wi){
        intrate=in;
    }
    void intrate1(float in,float de){
        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;
}

剑栈风樯各苦辛,别时冰雪到时春
2015-06-03 10:55
快速回复:程序有错,能否帮我在原有的基础上修改一番,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037610 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved