//该题目是一道关于银行的利息的计算问题!!我已经改过了在 c++工作界面中有一个错误,做的不好的话请不要取笑,谢谢!!!
#include
#define max 100;
class bank{
public:
char account[20];
char ID[20];
char name[10];
char home_addr[40];
int money;
int year;
int inputyear;
double all;
void getmessage();
void computeyear();
void computeallsalary();
void display();
static double rate1;
static double rate2;
static double rate3;
static double rate4;
static double rate5;
static double rate6;
static double rate7;
static double rate8;
};
void bank::getmessage()
{
cout<<"please input the person account:"< cin>>account;
cout<<"please input the person ID:"< cin>>ID;
cout<<"please input the person name:"< cin>>name;
cout<<"please input the person home_addr:"< cin>>home_addr;
cout<<"please input the money,you want to put into:"< cin>>money;
}
void bank::computeyear()
{
int i;
cout<<"please input what year now:"< cin>>i;
cout<<"please input which year you input money:"< cin>>inputyear;
year=i-inputyear;
}
void bank::computeallsalary()
{
if(money<=500)
all=money;
if(money>500&&money<=2000)
all=money+money*rate1*0.02;
if(money>2000&&money<=5000)
all=money+money*rate2*0.02;
if(money>5000&&money<=20000)
all=money+money*rate3*0.02;
if(money>20000&&money<=40000)
all=money+money*rate4*0.02;
if(money>40000&&money<=60000)
all=money+money*rate5*0.02;
if(money>60000&&money<=80000)
all=money+money*rate6*0.02;
if(money>80000&&money<=100000)
all=money+money*rate7*0.02;
if(money>100000)
all=money+money*rate8*0.02;
}
void bank::display()
{
cout<<"-----------------------------------------------------"< cout<<"帐号"<<" "<<"身份证号"<<" "<<"姓名"<<" "<<"家庭住址"<<" "<<"存入金额"<<" "<<"应得金额"< cout<<"------------------------------------------------------"< cout<<"account"<<" "<}
double bank::rate1=0.05;
double bank::rate2=0.10;
double bank::rate3=0.15;
double bank::rate4=0.20;
double bank::rate5=0.25;
double bank::rate6=0.30;
double bank::rate7=0.35;
double bank::rate8=0.40;
class people{
public:
char account[20];
char ID[20];
char name[10];
char home_addr[40];
int money;
int year;
int inputyear;
double all;
};
void main()
{
people p;
bank b;
b.getmessage();
strcpy(b.account,p.account);
strcpy(b.ID,p.ID);
strcpy(b.name,p.name);
strcpy(b.home_addr,p.home_addr);
strcpy(b.money,p.money);
b.computeyear();
b.year=p.year;
b.computeallsalary();
b.all=p.all;
cout< <<" "<}
--------------------next---------------------
#include
#include
using namespace std;
#define max 100;
class bank{
public:
char account[20];
char ID[20];
char name[10];
char home_addr[40];
int money;
int year;
int inputyear;
double all;
void computeyear();
void computeallsalary();
void display();
static double rate1;
static double rate2;
static double rate3;
static double rate4;
static double rate5;
static double rate6;
static double rate7;
static double rate8;
};
void bank::computeyear()
{
int i;
cout<<"please input what year now:"<cin>>i;
cout<<"please input which year you input money:"<cin>>inputyear;
year=i-inputyear;
}
void bank::computeallsalary()
{
if(money <=500)
all=money;
if(money >500 && money <=2000)
all=money+money*rate1*0.02*year;
if(money >2000 && money <=5000)
all=money+money*rate2*0.02*year;
if(money >5000 && money <=20000)
all=money+money*rate3*0.02*year;
if(money >20000 && money <=40000)
all=money+money*rate4*0.02*year;
if(money> 40000 && money <=60000)
all=money+money*rate5*0.02*year;
if(money >60000 && money <=80000)
all=money+money*rate6*0.02*year;
if(money >80000 && money <=100000)
all=money+money*rate7*0.02*year;
if(money >100000)
all=money+money*rate8*0.02*year;
}
void bank::display()
{
cout<<"-----------------------------------------------------"< cout<<"帐号"<<" "<<"身份证号"<<" "<<"姓名"<<" "<<"家庭住址"<<" "
<<"存入金额"<<" "<<"存入年限"<<" "<<"应得金额"< cout<<"------------------------------------------------------"< cout<<"account"<<" "<}
double bank::rate1=0.05;
double bank::rate2=0.10;
double bank::rate3=0.15;
double bank::rate4=0.20;
double bank::rate5=0.25;
double bank::rate6=0.30;
double bank::rate7=0.35;
double bank::rate8=0.40;
class people{
public:
char account[20];
char ID[20];
char name[10];
char home_addr[40];
int money;
int year;
int inputyear;
void getmessage();
};
void people::getmessage()
{
cout<<"please input the person account:"<cin>>account;
cout<<"please input the person ID:"<cin>>ID;
cout<<"please input the person name:"<cin>>name;
cout<<"please input the person home_addr:"<cin>>home_addr;
cout<<"please input the money,you want to put into:"<cin>>money;
}
void main()
{
people p;
bank b;
p.getmessage();
strcpy(b.account,p.account);
strcpy(b.ID,p.ID);
strcpy(b.name,p.name);
strcpy(b.home_addr,p.home_addr);
b.money=p.money;
b.computeyear();
b.computeallsalary();
b.display();
}
--------------------next---------------------
//该题目是一道关于银行的利息的计算问题!!我已经改过了在 c++工作界面中有一个错误,做的不好的话请不要取笑,谢谢!!!
#include
#define max 100;
class bank{
public:
char account[20];
char ID[20];
char name[10];
char home_addr[40];
int money;
int year;
int inputyear;
double all;
void getmessage();
void computeyear();
void computeallsalary();
void display();
static double rate1;
static double rate2;
static double rate3;
static double rate4;
static double rate5;
static double rate6;
static double rate7;
static double rate8;
};
void bank::getmessage()
{
cout<<"please input the person account:"<cin>>account;
cout<<"please input the person ID:"<cin>>ID;
cout<<"please input the person name:"<cin>>name;
cout<<"please input the person home_addr:"<cin>>home_addr;
cout<<"please input the money,you want to put into:"<cin>>money;
}
void bank::computeyear()
{
int i;
cout<<"please input what year now:"<cin>>i;
cout<<"please input which year you input money:"<cin>>inputyear;
year=i-inputyear;
}
void bank::computeallsalary()
{
if(money<=500)
all=money;
if(money>500&&money<=2000)
all=money+money*rate1*0.02;
if(money>2000&&money<=5000)
all=money+money*rate2*0.02;
if(money>5000&&money<=20000)
all=money+money*rate3*0.02;
if(money>20000&&money<=40000)
all=money+money*rate4*0.02;
if(money>40000&&money<=60000)
all=money+money*rate5*0.02;
if(money>60000&&money<=80000)
all=money+money*rate6*0.02;
if(money>80000&&money<=100000)
all=money+money*rate7*0.02;
if(money>100000)
all=money+money*rate8*0.02;
}
void bank::display()
{
cout<<"-----------------------------------------------------"< cout<<"帐号"<<" "<<"身份证号"<<" "<<"姓名"<<" "<<"家庭住址"<<" "<<"存入金额"<<" "<<"时间长(年)"<<"应得金额"< cout<<"------------------------------------------------------"< cout<<"account"<<" "<}
double bank::rate1=0.05;
double bank::rate2=0.10;
double bank::rate3=0.15;
double bank::rate4=0.20;
double bank::rate5=0.25;
double bank::rate6=0.30;
double bank::rate7=0.35;
double bank::rate8=0.40;
class people{
public:
// people();
char account[20];
char ID[20];
char name[10];
char home_addr[40];
int money;
int year;
int inputyear;
double all;
void getmessage();
};
void people::getmessage()
{
cout<<"please input the person account:"<cin>>account;
cout<<"please input the person ID:"<cin>>ID;
cout<<"please input the person name:"<cin>>name;
cout<<"please input the person home_addr:"<cin>>home_addr;
cout<<"please input the money,you want to put into:"<cin>>money;
}
主函数
#include
#include"H1.H"
#include
void main()
{
people p;
bank b;
p.getmessage();
strcpy(b.account,p.account);
strcpy(b.ID,p.ID);
strcpy(b.name,p.name);
strcpy(b.home_addr,p.home_addr);
b.money=p.money;
b.computeyear();
b.computeallsalary();
b.display();
}
我已调试出结果了
你可以试一试
--------------------next---------------------
阅读(1202) | 评论(0) | 转发(0) |