C++作业3

项目1:个人所得税计算器

#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;
}



你可能感兴趣的:(C++作业3)