第三周项目1-个人所得税计算器(if语句的嵌套)

来源:互联网 发布:js 绝对值 math.abs 编辑:程序博客网 时间:2024/05/22 03:10

问题及代码:

/* *Copyright (c) 2016,烟台大学计算机学院 *All rights reserved. *文件名称:zwj.cpp *作    者:张伟晶 *完成日期:2016年3月12日 *版 本 号:v1.0 * *问题描述:编写选择结构程序,输入个人月收入总额,计算他本月应缴税款和税后收入。 *输入描述:个人月收入总额 *程序输出:本月应缴个人所得税、/税后收入 */#include <iostream>using namespace std;int main( ){    double dSalary,dTax=0,dNetIncome=0,dg;    cout<<"请输入您本月的收入总额(元):";    cin>>dSalary;    if(dSalary<=3500)        cout<<"您不需要缴税.\n";    else    {        dg=dSalary-3500;        if(dg<=1500)        {            dTax=dg*0.03-0;        }        else if(dg>1500 && dg<=4500)        {            dTax=dg*0.1-105;        }        else if(dg>4500 && dg<=9000)        {            dTax=dg*0.2-555;        }        else if(dg>9000 && dg<=35000)        {            dTax=dg*0.25-1005;        }        else if(dg>35000 && dg<=55000)        {            dTax=dg*0.3-2755;        }        else if(dg>55000 && dg<=80000)        {            dTax=dg*0.35-5505;        }        else        {            dTax=dg*0.45-13505;        }        dNetIncome=dSalary-dTax;        cout<<"您本月应缴个人所和税 "<<dTax<<" 元,税后收入是 "<<dNetIncome<<" 元。\n";    }    cout<<"依法纳税,共享繁荣。谢谢使用!\n";    return 0;}

运行结果:

知识点总结:

        if语句的嵌套。

学习心得:

       加强了if语句的嵌套的理解,加油!!!


0 0
原创粉丝点击