C++作业3
2016-04-07 10:43
316 查看
项目1:个人所得税计算器
项目3:定期存款利息计算器
项目4:多分数段函数求值
#include <iostream> using namespace std; int main( ) { double dSalary,dTax=0,dNetIncome=0,dValue; cout<<"请输入您本月的收入总额(元):"; cin>>dSalary;// 下面求解应缴个人所和税dTax和税后收入dNetIncome dValue=dSalary-3500; if(dValue<=0) dTax=0.0; else if(0<dValue&&dValue<=1500) dTax=dValue*0.03-0.0; else if(dValue<=4500)dTax=dValue*0.10-105.0; else if(dValue<=9000)dTax=dValue*0.20-555.0; else if(dValue<=35000)dTax=dValue*0.25-1005.0; else if(dValue<=55000)dTax=dValue*0.30-2755.0; else if(dValue<=80000)dTax=dValue*0.35-5505.0; else if(dValue>80000)dTax=dValue*0.45-13505.0; dNetIncome=dSalary-dTax; cout<<"您本月应缴个人所和税 "<<dTax<<" 元,税后收入是 "<<dNetIncome<<" 元。\n"; cout<<"依法纳税,共享繁荣。谢谢使用!\n"; return 0; }
项目3:定期存款利息计算器
#include <iostream.h> void main() { double money,interest,all; int code; cout<<"欢迎使用利息计算器!"<<endl; cout<<"请输入存款金额:"; cin>>money; cout<<"==========存款期限=========="<<endl; cout<<"1. 3个月\n2. 6个月\n3. 一年\n4. 二年\n5. 三年\n6. 五年 "<<endl; cout<<"请输入存款期限的代号:"; cin>>code; switch(code) { case 1: { interest=money*0.031*0.250; all=interest+money; break; } case 2: { interest=money*0.033*0.5; all=interest+money; break; } case 3: { interest=money*0.035*1; all=interest+money; break; } case 4: { interest=money*0.044*2; all=interest+money; break; } case 5: { interest=money*0.05*3; all=interest+money; break; } case 6: { interest=money*0.055*5; all=interest+money; break; } } cout<<"到期利息为:"<<interest<<"元,"<<"本息合计共计"<<all<<"元"<<endl; cout<<"感谢您的使用,欢迎下次光临!"<<endl; }
项目4:多分数段函数求值
#include <iostream.h> #include <cmath> void main() { double x,y; cout<<"请输入x的值:"; cin>>x; if (x<2) y=x; else if (x<6) y=x*x+1; else if (x<10) y=sqrt(x+1); else if (x>=10) y=1/(x+1); cout<<"y="<<y<<endl; }
相关文章推荐
- 建站服务器的最优选择之Windows Or Linux
- nginx 并发数问题思考:worker_connections,worker_processes与 max clients
- js 判断一个json里是不是包含某个key
- linux线程同步03
- Android动态换肤(一、应用内置多套皮肤)
- 分享下android中路径动画svg格式的(一)
- 利用StegSolve、Python对.jpg文件进行分析
- Axis2创建WebService实例
- 2008
- this指针指向的彻底理解
- Linux下使用wget命令下载百度云盘文件
- ffmpeg编程基础和一些常见问题的解答
- mysql update使用子查询
- Android动态换肤(一、应用内置多套皮肤)
- LeetCode 102, 103, 107. Binary Tree Level Order Traversal i, ii, Zigzag Level Order
- 52. N-Queens II
- 给Eclipse提速的7个技巧
- Android SDK 下载
- ACM:POJ-1979 Red And Black(JAVA的字符数组输入以及标记方法)
- java.util.zip.ZipException: zip file is empty