发布网友 发布时间:2024-10-24 16:03
共3个回答
热心网友 时间:2024-10-24 22:44
int test_personal_income_tax() {
printf("个人所得税计算\n");
printf("王明 李敏 张年 文章 李鹤\n");
float income[5];
int i;
for (i = 0; i < 5; i++) {
scanf("%f", &income[i]);
}
for (i = 0; i < 5; i++) {
printf("%4.1f ", computer_tax(income[i]));
}
return 0;
}
float computer_tax(float income) {
float tax[4] = { 0.05, 0.10, 0.15, 0.20 };//利率
float tax1[5] = { 2000, 3000, 4000, 5000,60000};//底数
float temp = 0, result = 0;
int i;
if (income > tax1[0]) {
for (i = 0; i < 4; i++) {
temp = tax1[i + 1] - tax1[i];//plus
if (income - tax1[i] > temp) {
result += temp * tax[i];
} else if(income - tax1[i] > 0){
result += (income -tax1[i]) * tax[i];
}
}
}
return result;
}
热心网友 时间:2024-10-24 22:44
#include "stdio.h"
#define MAX_NUM (5)
float CalcTax(int salary)
{
if (salary <= 2000)
{
return 0;
}
float tax = 0;
int level = 0;
level = salary / 1000 > 5 ? 5 : salary / 1000;
switch (level)
{
case 5:
tax += (salary - 5000) * 0.2;
case 4:
tax += ((salary - 4000) > 1000 ? 1000 : (salary - 4000)) * 0.15;
case 3:
tax += ((salary - 3000) > 1000 ? 1000 : (salary - 3000)) * 0.1;
case 2:
tax += ((salary - 2000) > 1000 ? 1000 : (salary - 2000)) * 0.05;
default:
break;
}
return tax;
}
int main()
{
int salary[MAX_NUM];
int i = 0;
for(; i < MAX_NUM; ++i)
{
scanf("%d", salary + i);
}
float tax[MAX_NUM] = {0};
for(i = 0; i < MAX_NUM; ++i)
{
tax[i] = CalcTax(salary[i]);
printf("%.2f ", tax[i]);
}
return 0;
}追问谢谢。我试下。对的话。直接好评,最佳。谢咯!
热心网友 时间:2024-10-24 22:44
刚开始做直销结算软件吧?呵呵 程序不是这样做的!追问不是。我们公选课,老师出的题、我们是学机电专业的。出这个题,做不起啊
追答哦 这么出题有点*!应该是表现软件+数据库 这是科学做法!你们老师这么要求不太实际!呵呵,不过这个弄懂了 比较有用!