⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shiyan10.3.cpp

📁 模仿港台《百万富翁》节目
💻 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 + -