成都网站建设设计

将想法与焦点和您一起共享

C语言用函数计算税额,c语言税率计算题目

使用c语言编程,用函数实现一个计算器,在主函数中调用函数,包括加减乘除,乘方,绝对值和sin函数。

#includestdio.h

创新互联2013年至今,是专业互联网技术服务公司,拥有项目做网站、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元柳北做网站,已为上家服务,为柳北各地企业和个人服务,联系电话:18980820575

#includestdlib.h

double jia(double a,double b)

{

return a+b;

}

double jian(double a,double b)

{

return a-b;

}

double cheng(double a,double b)

{

return a*b;

}

double chu(double a,double b)

{

return a/b;

}

double juedui(double a)

{

return a0 ? a : -a;

}

double chengfang(double a,double b)

{

return pow(a,b);

}

double sinx(double a)

{

return sin(a);

}

int main()

{

int m;

double a,b;

while(1)

{

printf("请输入第一个操作数:");

scanf("%lf",a);

printf("0、退出\n1、加\n2、减\n3、乘\n4、除\n5、绝对值\n6、乘方\n7sin、\n请选择一个:");

scanf("%d",m);

if(1==m || 2==m || 3==m || 4==m || 6==m)

{

printf("请输入第二个操作数:");

scanf("%lf",b);

}

switch(m)

{

case 0:

exit(0);

break;

case 1:

printf("%lf+%lf=%lf\n",a,b,jia(a,b));

break;

case 2:

printf("%lf-%lf=%lf\n",a,b,jian(a,b));

break;

case 3:

printf("%lf*%lf=%lf\n",a,b,cheng(a,b));

break;

case 4:

if(0.0==b)

{

printf("除数不能为0。\n");

}

else

{

printf("%lf/%lf=%lf\n",a,b,chu(a,b));

}

break;

case 5:

printf("|%lf|=%lf\n",a,juedui(a));

break;

case 6:

printf("%lf的%lf方=%lf\n",a,b,chengfang(a,b));

break;

case 7:

printf("sin(%lf)=%lf\n",a,sinx(a));

break;

default:

printf("无法处理的命令。\n");

break;

}

}

system("PAUSE");

return EXIT_SUCCESS;

}

C语言编程输入某单位全年应纳所得额数目,计算并输出应缴税额和实际所得

你看我的理解对不。如果有问题,HI我。

/*表达的有点不清楚,如果x是20000,按10%算还是按20%算*/

#includestdio.h

int main(void)

{

double tax=0,money,m;

int c;

printf("请输入全年应纳所得额数目:\n");

scanf("%lf",money);

m=money;

if(money/100008)

c=8;

else

c=(int)money/10000;

switch(c)//找到一个入口,顺次相加各个级应纳税额。

{

case 8:tax+=(money-80000)*0.35;money=80000;

case 7:

case 6:

case 5:

case 4:tax+=(money-40000)*0.30;money=40000;

case 3:

case 2:tax+=(money-20000)*0.20;money=20000;

case 1:tax+=(money-10000)*0.10;money=10000;

case 0:tax+=money*0.05;break;

default:printf("Data Error!\n");

}

printf("应纳税额:%.2f\n",tax);

printf("最终所得:%.2f\n",m-tax);

return 0;

}

为了便于你验证程序执行结果:下面的可以多次执行,直到你输入的money不大于0.

#includestdio.h

int main(void)

{

while(1)

{

double tax=0,money,m;

int c;

printf("请输入全年应纳所得额数目:\n");

scanf("%lf",money);

if(money=0)

break;

m=money;

if(money/100008)

c=8;

else

c=(int)money/10000;

switch(c)//找到一个入口,顺次相加各个级应纳税额。

{

case 8:tax+=(money-80000)*0.35;money=80000;

case 7:

case 6:

case 5:

case 4:tax+=(money-40000)*0.30;money=40000;

case 3:

case 2:tax+=(money-20000)*0.20;money=20000;

case 1:tax+=(money-10000)*0.10;money=10000;

case 0:tax+=money*0.05;break;

default:printf("Data Error!\n");

}

printf("应纳税额:%.2f\n",tax);

printf("最终所得:%.2f\n",m-tax);

}

return 0;

}

c语言工资税收问题

首先,switch适用于处理有明确对比目标和对比点的判断的,比如等于多少的判断适合用switch,而上面的范围性的还是用if else比较好,如下:

int r= 0;//去税额利率

int s = 10000;//工资

float f = 0; //税后工资总额

if(sprintf("%s","error input number");

else(sr = 1;

else

if(sr = 0.95;

else

if(sr = 0.9;

else

if(sr = 0.85;

else

if(sr = 0.8;

else

r = 0.15;

f = s*r;

最后结果f就是你的税后工资总额了。

C语言是一门面向过程、抽象化的通用程序设计语言,广泛应用于底层开发。C语言能以简易的方式编译、处理低级存储器。C语言是仅产生少量的机器语言以及不需要任何运行环境支持便能运行的高效率程序设计语言。尽管C语言提供了许多低级处理的功能,但仍然保持着跨平台的特性,以一个标准规格写出的C语言程序可在包括一些类似嵌入式处理器以及超级计算机等作业平台的许多计算机平台上进行编译。

现在最新的C语言标准是C18。

C语言是一门面向过程的计算机编程语言,与C++、Java等面向对象编程语言有所不同。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、仅产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。C语言描述问题比汇编语言迅速,工作量小、可读性好,易于调试、修改和移植,而代码质量与汇编语言相当。

C语言一般只比汇编语言代码生成的目标程序效率低10%~20%。因此,C语言可以编写系统软件。

二十世纪八十年代,美国国家标准局为了避免各开发厂商用的C语言语法产生差异,给C语言制定了一套完整的美国国家标准语法,称为ANSI C。作为C语言最初的标准。2011年12月8日,国际标准化组织(ISO)和国际电工委员会(IEC)发布的C11标准是C语言的第三个官方标准,也是C语言的最新标准,该标准更好的支持了汉字函数名和汉字标识符,一定程度上实现了汉字编程。

C语言用函数strlen计算

C语言规定,对于没有明确初始化的部分,默认初始化为0, 这个和字符串结束符\0的值是相同的。

于是str中存的就是

string加上6个\0

而strlen是到\0结束计算的,这样,字符串长度就是6

选A

c语言计算器程序设计包含加减乘除简单的函数运算

实用计算器之程序设计

[摘 要]多用计算器的构思及设计代码

[关键词]多用计算器;设计

数值计算可以说是日常最频繁的工作了,WIN98提供了“计算器”软件供用户使用,该软件可以处理一般的一步四则运算,例如:3+2、5/3等等,但在日常中用户经常遇到多步四则运算问题,例如:3+4*5-4/2,45*34/2+18*7等等,那么该个计算器就无法胜任了,作者制作了一个实用的计算器,该计算器新增不少功能:(程序界面如图)

1.可以实现连续的四则运算

2.可以实现输入式子的显示

3.可以方便计算个人所得税

4.鼠标、键盘均可输入数据

5.操作界面友好

6.击键可发声

构建该个计算器所需研究及解决的核心问题有如下几个:1、连乘求值?2、字符显示 3、键盘输入?4、击键发声?5、个人所得税法规,为了使大家对程序有更一步认识,现将代码提供给读者参考:

*定义数组及窗体变量

Dim number2(0 To 50) As Double

Dim number(0 To 50) As Double

Dim z As Integer

Dim k As Integer, r As Integer

Dim j As Integer

Dim str As String

*调用名为“playsound”的API函数

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_FILENAME = H20000?

Private Const SND_ASYNC = H1?

Private Const SND_SYNC = H0

*判断通用过程

Sub pianduan(p As String)

r = 0

Dim i As Integer, l As Integer, h As Integer

h = 0

i = 1

If InStr(Trim$(p), "*") 0 Then

k = k + 1

End If

If InStr(Trim$(p), "/") 0 Then

r = r + 1

End If

End Sub

*连乘通用过程(略)

*各按钮事件过程

Private sub Command1_Click(Index As Integer)

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text1.Text = Text1.Text + Command1(Index).Caption

Text2.Text = Text2.Text + Command1(Index).Caption

Text1.SetFocus

End Sub

rivate sub Command10_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

str = Text3.Text

End Sub

Private sub Command11_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text3.Text = str

End Sub

rivate sub Command2_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "+"

z = z + 1

Text1.SetFocus

End Sub

rivate sub Command3_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "-"

Text1.Text = Text1.Text "-"

z = z + 1

Text1.SetFocus

End Sub

Private sub Command4_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text2.Text = Text2.Text + "*"

Text1.Text = Text1.Text + "*"

Text1.SetFocus

End Sub

rivate sub Command5_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text2.Text = Text2 + "/"

Text1.Text = Text1 + "/"

Text1.SetFocus

End Sub

Private sub Command6_Click()

PlaySound App.Path "\sound.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

z = z + 1

Dim dengyu As Double

Dim v As Integer

For v = 0 To 50

dengyu = dengyu + number2(v)

Next v

If dengyu 0 Then

Text3.ForeColor = HFF

Else

Text3.ForeColor = HFF0000

End If

Text3.Text = dengyu

Text1.SetFocus

If Len(Text3.Text) = 14 Then

calcresult.Show

End If

End Sub

rivate sub Command7_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

z = 0: k = 0: r = 0: j = 0

Dim i As Integer

For i = 0 To 50

number(i) = 0

number2(i) = 0

Next i

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End Sub

rivate sub Command8_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

If Val(Text3.Text) = 0 Then

MsgBox "除数不能为0!"

Exit Sub

End If

Text3.Text = 1 / Val(Text3.Text)

End Sub

Private sub Command9_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text3.ForeColor = HFF0000

Text3.Text = Val(Text3.Text) * Val(Text3.Text)

End Sub

rivate sub muninternet_Click()

Dim i

i = Shell("C:\Program Files\InternetExplorer\iexplore.exe", vbMaximizedFocus)

End Sub

rivate sub munmp3_Click()

Dim i

i = Shell("C:\Program Files\Windows Media Player\mplayer2", vbNormalNoFocus)

End Sub

Private sub munsm_Click()

Dialog.Show

End Sub

rivate sub muntax_Click()

tax.Show

End Sub

rivate sub munver_Click()

ver.Show

End Sub

rivate sub notepad_Click()

Dim i

i = Shell("c:\windows\notepad", vbNormalFocus)

End Sub

Private sub Text1_KeyPress(KeyAscii As Integer)

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim num As Integer

num = Val(KeyAscii)

If num 47 And num 58 Then

Text1.Text = Text1.Text + CStr(num - 48)

Text2.Text = Text2.Text + CStr(num - 48)

End If

If num = 46 Then

Text1.Text = Text1.Text + "."

Text2.Text = Text2.Text + "."

End If

If KeyAscii = 43 Then

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "+"

z = z + 1

End If

If KeyAscii = 45 Then

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "-"

Text1.Text = Text1.Text "-"

z = z + 1

End If

If KeyAscii = 42 Then

Text2.Text = Text2.Text + "*"

Text1.Text = Text1.Text + "*"

End If

If KeyAscii = 47 Then

Text2.Text = Text2.Text + "/"

Text1.Text = Text1.Text + "/"

End If

If KeyAscii = vbKeyReturn Then

PlaySound App.Path "\sound.wav", 0, SND_SYNC

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

z = z + 1

Dim dengyu As Double

Dim v As Integer

For v = 0 To 50

dengyu = dengyu + number2(v)

Next v

If dengyu 0 Then

Text3.ForeColor = HFF

Else

Text3.ForeColor = HFF0000

End If

Text3.Text = dengyu

End If

If KeyAscii = vbKeyEscape Then

z = 0: k = 0: r = 0: j = 0

Dim i As Integer

For i = 0 To 50

number(i) = 0

number2(i) = 0

Next i

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End If

If Len(Text3.Text) = 14 Then

calcresult.Show

End If

End Sub

rivate sub Text3_Change()

tax2.Text1 = Text3.Text

End Sub

c语言工资纳税系统

#define gongzi a

#define b 1600

#includestdio.h

#include"工资纳税系统.h"

void main()

{

double f(int a);

int a;

float c;

printf("\n请输入工资:");

scanf("%d",gongzi);

c=f(gongzi);

printf("应纳税所得额为:%.2f\n",gongzi-c);

}

double f(int gongzi)

{

double z;

int x;

x=gongzi-b;

if(gongzib)

z=0;

else if(x500)

z=x*0.05;

else if(x2000)

z=500*0.05+(x-500)*0.1;

else if(x5000)

z=500*0.05+1500*0.1+(x-2000)*0.15;

else if(x20000)

z=500*0.05+1500*0.1+3000*0.15+(x-5000)*0.2;

else if(x40000)

z=500*0.05+1500*0.1+3000*0.15+15000*0.2+(x-20000)*0.25;

else if(x60000)

z=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+(x-40000)*0.3;

else if(x80000)

z=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+20000*0.3+(x-60000)*0.35;

else if(x100000)

z=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+20000*0.3+20000*0.35+(x-80000)*0.4;

else

z=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+20000*0.3+20000*0.35+20000*0.4+(x-100000)*0.45;

return(z);

}


分享名称:C语言用函数计算税额,c语言税率计算题目
文章分享:http://chengdu.cdxwcx.cn/article/dscgcjh.html