C++作业3

来源:互联网 发布:java enum 反射 编辑:程序博客网 时间:2024/05/17 00:58

1,个人所得税计算器

一,运行及代码

/*文件名称:个人所得税计算器 作者:庞泽宇 完成时间:2017年4月2号 版本号:V1.0 对任务及求解方法的描述部分:无 *输入描述:输入工资 *问题描述:设置C++程序计算个人所得税*程序输出:税后工资*问题分析:无 *算法设置:if语句*/  #include <iostream>     using namespace std;  int main( )  {      double dSalary,dTax,dNetIncome,a;dTax=0,dNetIncome=0;    cout<<"请输入您本月的收入总额(元):";      cin>>dSalary;if (dSalary<=3500){dTax=0;dNetIncome=dSalary;}else{a=dSalary-3500;if (a>0&&a<=1500)           dTax=a*0.03-0;dNetIncome=dSalary-dTax;    if (a>1500&&a<=4500)           dTax=a*0.10-105;dNetIncome=dSalary-dTax;if  (a>4500&&a<=9000)           dTax=a*0.20-555;dNetIncome=dSalary-dTax;    if  (a>9000&&a<=35000)           dTax=a*0.25-1005;dNetIncome=dSalary-dTax;    if  (a>35000&&a<=55000)           dTax=a*0.30-2755;dNetIncome=dSalary-dTax;if (a>55000&&a<=80000)           dTax=a*0.35-5505;dNetIncome=dSalary-dTax;if (a>80000)           dTax=(dSalary-3500)*0.45-13505;dNetIncome=dSalary-dTax;}    cout<<"您本月应缴个人所和税 "<<dTax<<" 元,税后收入是 "<<dNetIncome<<" 元。\n";      cout<<"依法纳税,共享繁荣。谢谢使用!\n";      return 0;  }  


二,运行结果


2,本月有几天

一,问题及代码

/*文件名称:本月有几天?作者:庞泽宇 完成时间:2017年4月2号 版本号:V1.0 对任务及求解方法的描述部分:无 *输入描述:输入年份和月份 *问题描述:设置C++程序计算本月有几天*程序输出:本月有几天*问题分析:无 *算法设置:if语句*/ #include <iostream>     using namespace std;  int main( )  {int year,month;cout<<"输入年份和月份:"<<endl;cin>>year>>month;if (year%4==0&&year%100!=0||year%400==0){cout<<"输出年份是闰年"<<endl;    if (month==2)cout<<"本月有29天"<<endl;if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)cout<<"本月有31天"<<endl;if (month==4||month==6||month==9||month==11)            cout<<"本月有31天"<<endl;}else{        cout<<"输出年份是平常年"<<endl;        if (month==2)cout<<"本月有28天"<<endl;if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)cout<<"本月有31天"<<endl;if (month==4||month==6||month==9||month==11)            cout<<"本月有31天"<<endl;}return 0;}    


二,运行结果


3,定期存款利息计算

一,问题及代码

/*文件名称:定期存款利息计算器作者:庞泽宇 完成时间:2017年4月2号 版本号:V1.0 对任务及求解方法的描述部分:无 *输入描述:输入存款和年份 *问题描述:设置定期存款利息计算器*程序输出:定期存款和利息*问题分析:无 *算法设置:switch语句*/ #include <iostream>     using namespace std;  int main( )  {int a,b,c,d;cout<<"欢迎使用利息计算器!\n";cout<<"请输入存款金额:\n";cout<<"=======存款期限=======\n";    cout<<"1,3个月\n";    cout<<"2,6个月\n";cout<<"3,一年\n";cout<<"4,二年\n";cout<<"5,三年\n";cout<<"6,五年\n";cout<<"请输入存款期限的代码:\n";    cout<<"到期利息为:\n";cout<<"本息合计共:\n";cout<<"感谢您的使用,欢迎下次光临!\n";    cin>>a>>b;char grade='A';grade=96+b;switch (grade){ case'A':c=a*0.031*0.25;break;  case'B':c=a*0.033*0.50;break;  case'C':c=a*0.035*1;break;  case'D':c=a*0.044*2;break;  case'E':c=a*0.050*3;break;  default:c=a*0.055*5;break;}cout<<b;return 0;}


二,运行结果





0 0
原创粉丝点击