C+++作業3
2357 ワード
項目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<<" 。
";
cout<<" , 。 !
";
return 0;
}
項目3:定期預金利息計算機
#include <iostream.h>
void main()
{
double money,interest,all;
int code;
cout<<" !"<<endl;
cout<<" :";
cin>>money;
cout<<"========== =========="<<endl;
cout<<"1. 3
2. 6
3.
4.
5.
6. "<<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;
}