?? shiyan10.3.cpp
字號:
#include<iostream.h>
#include<time.h>
#include<stdlib.h>
class incomec
{
public :
void setWage(double m){wage=m;}
static void setTaxrate(double n,incomec *a)
{ a->wage=n;
if(a->wage-2000>=10000) a->taxrate=0.20;
if(a->wage-2000>=5000) a->taxrate=0.15;
if(a->wage-2000>=2000) a->taxrate=0.10;
if(a->wage-2000>=0) a->taxrate=0.05;
else a->taxrate=0;
}
static void calIncome(double n,incomec *a)
{ a->wage=n;
if(a->taxrate==0) cout<<"no tax !"<<endl;
else
{
cout<<"the wage is "<<a->wage <<" dallor"<<" the taxrate is "<<a->taxrate<<endl;
cout<<"the income is "<<a->wage*(1-a->taxrate)<<"dallor"<<endl<<endl;
a->wage=0;a->taxrate=0;
}
}
private:
double income;
static double wage;
static double taxrate;
};
double incomec::wage=0;
double incomec::taxrate=0;
void main()
{ double n;
incomec a;
srand(time(0));
for(int i=0;i<5;i++)
{
do
n=rand();
while(n<1500&&n>100000);
a.setWage(n);
incomec::setTaxrate(n,&a);
incomec::calIncome(n,&a);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -