工资纳税系统(C++)

来源:互联网 发布:明基显示器 知乎 编辑:程序博客网 时间:2024/04/29 16:56

#include  <iostream>
using namespace std;
class Fack
{
public:
 ////////////////////
 Fack(){ns = 0; q=0;}
 ~Fack(){}
 ///////////////////
 //float fun(float&);
 float fun();
 void display();
 /////////////
 void setns(float&);
 /////////////
private:
 float gongzi;//公民工资
 float ns;//纳税的款
 float q;//需要纳税的部分
};

void Fack::setns(float &gz)
{
 //cout<<"欢迎来到纳税系统!"<<endl;
 //cout<<"请输入您要纳税的工资:";
 //cin>>gongzi;
 gongzi=gz;
}

//float Fack::fun(float &gongzi)
float Fack::fun()
{
  
 q=gongzi-1600;
 if(q<=0)
   return ns;
  else
  {
   if(q<=500){
   ns=q*0.05;}
   else
   {
    if(q>500&&q<=2000){
     ns=25+(q-500)*0.1;}
    else
    {
     if(q>2000&&q<=5000){
      ns=25+150+(q-2000)*0.15;}
     else
     {
      if(q>5000&&q<=20000){
       ns=25+150+450+(q-5000)*0.2;}
      else
      {
       if(q>20000&&q<=40000){
        ns=25+150+450+3000+(q-20000)*0.25;}
       else
       {
        if(q>40000&&q<=60000){
         ns=25+150+450+3000+5000+(q-40000)*0.3;}
        else
        {
         if(q>60000&&q<=80000){
                                  ns=25+150+450+3000+5000+6000+(q-60000)*0.35;}
         else
         {
          if(q>80000&&q<=100000){
           ns=25+150+450+3000+5000+6000+7000+(q-80000)*0.4;}
          else
          {
           if(q>100000){
            ns=25+150+450+3000+5000+6000+7000+8000+(q-100000)*0.45;}
          }
         }
        }
       }
      }
     }
    }

   }
  }
  return 0;
}
void Fack::display()
{
    cout<<"您需要被政府抢走的劳动报酬是:"<<ns<<endl; 
}
int main()
{
    Fack b;
 float a;
 cout<<"欢迎来到纳税系统!"<<endl;
 cout<<"如果需要退出,请按0!"<<endl;
 
 while (a != 0){
 cout<<"请输入您要纳税的工资:"<<endl;
 cin>>a;
 b.setns(a);
 b.fun();
 b.display();
 }
 return 0;
}