Program会要求一些个人资料,如IC、名字、生日等等。最后要求Total income, total relief, 和total rebate。
软件功用:
可以不断输入很多户口,然后储存起来。
之后,利用IC搜索资料和显示税务。
税务的算法是正确的。
Coding样本在#25-27楼!由衷感谢Super-Tomato帮忙。
各位高手,我还有一些想请教你们。见#27楼。
[ 本帖最后由 无我不在 于 2009-1-23 11:05 PM 编辑 ]
|
8326| 60
|
【入门C作业】【strcmp / for / while】 #25楼 有Debug Coding提供。 |
原帖由 无我不在 于 2009-1-10 11:23 PM 发表
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
int code=37, i=-1;
char choice=0, icno_search[8];
char name[10][50]={""}, icno[10][8]={""}, DOB[10][10]={""}, sex[10]={""};
float total_income[10]={0}, total_relief[10]={0}, total_rebate[10]={0}, pre_payment[10]={0}, taxable_amount[10]={0};
float amount_payment[10]={0};
while(choice!='D'&& choice!='d')
{
printf("Tax Advisor Program\n");
printf("(A)\tDisplay taxation rate\n");
printf("(B)\tInput tax payer's particulars\n");
printf("(C)\tCompute and display tax payable\n");
printf("(D)\tQuit\n");
printf("Enter Choice: ");
flushall();
scanf("%c", &choice);
switch(choice)
{
case 'a' :
case 'A' : printf("\n\nTax Rate Information Table\n");
printf("==========================");
printf("\n\t\tIncome\t\tRate\n");
printf("\t\t$\t\t(%c)\n", code);
printf("On the frist\t20,000\t\t0\n");
printf("On the next\t10,000\t\t3.5\n");
printf("On the next\t10,000\t\t5.5\n");
printf("On the next\t40,000\t\t8.5\n");
printf("On the next\t80,000\t\t14\n");
printf("On the next\t160,000\t\t17\n");
printf("Above\t\t320,000\t\t20\n");
printf("\n\n");
break;
case 'b' :
case 'B' : i = i + 1;
printf("\n\n");
printf("Fill Your Descriptions in the following\n");
printf("=======================================");
printf("\nEnter NRIC no.: ");
flushall();
scanf("%s", &icno);
printf("Enter Name: ");
flushall();
gets(name);
printf("Enter Date of Birth(DD-MM-YYYY): ");
flushall();
gets(DOB);
printf("Enter Sex(M/F): ");
flushall();
scanf("%c", &sex);
printf("Enter Total Income: $");
flushall();
scanf("%f", &total_income);
printf("Enter Total Relief: $");
flushall();
scanf("%f", &total_relief);
printf("Enter Total Rebate: $");
flushall();
scanf("%f", &total_rebate);
printf("\n");
printf("**To compute and display your amount payment, please press C to continue.\n\n\n");
pre_payment = total_income - total_relief;
if(pre_payment>=0 && pre_payment<20000)
{
taxable_amount = pre_payment * 0;
}
else
{
if(pre_payment > 20000 && pre_payment <= 30000)
{
taxable_amount = 0 + (pre_payment-20000) * 0.035;
}
else
{
if(pre_payment > 30000 && pre_payment <= 40000)
{
taxable_amount = 350 + (pre_payment-30000) * 0.055;
}
else
{
if(pre_payment > 40000 && pre_payment <= 80000)
{
taxable_amount = 900 + (pre_payment-40000) * 0.085;
}
else
{
if(pre_payment > 80000 && pre_payment <= 160000)
{
taxable_amount = 4300 + (pre_payment-80000) * 0.14;
}
else
{
if(pre_payment > 160000 && pre_payment <= 320000)
{
taxable_amount = 15500 + (pre_payment-160000) * 0.17;
}
else
{
taxable_amount = 42700 + (pre_payment-320000) * 0.2;
}
}
}
}
}
}
amount_payment = taxable_amount - total_rebate;
break;
case 'c' :
case 'C' : i = i + 1;
printf("Enter Your NRIC: ");
flushall();
gets(icno_search);
if(strcmp(icno, icno_search) == 0)
{
printf("\n\nYour Total Amount Payment");
printf("\n=========================");
printf("\nNRIC\t\t\t : %s", icno);
printf("\nName\t\t\t : %s", name);
printf("\nDate of Brith\t\t : %s\n", DOB);
printf("Sex\t\t\t : %c\n\n", sex);
printf("Total income\t\t : $%9.2f\n", total_income);
printf("\t\tLess relief: -$%9.2f\n", total_relief);
printf("Total taxable amount\t : $%9.2f\n", taxable_amount);
printf("\t\tLess rebate: -$%9.2f\n", total_rebate);
printf("\n");
printf("Amount payment\t\t : $%9.2f\n", amount_payment);
}
printf("\n");
printf("**If you don't use this Tax Advisor Program, please press D to QUIT.\n\n\n");
break;
case 'd' :
case 'D' : printf("\nThank You... Have a Nice Day!");
printf("\n\n");
break;
default : printf("\nInvalid Choice! Please try again...");
printf("\n\n");
}
}
printf("\n\n");
}

原帖由 无我不在 于 2009-1-11 07:17 AM 发表
我在google搜索过了,ARRAY的示范都已经分别指定的位子(空间),不然就是用for loop (exp. for(i=0; i number of store ; y ==> size of character
**difference with int and float**
int[x][y] = {"")
fl ...
#include <stdio.h>
int main()
{
char name[3][50] = {};
int age[3];
for(int a=0; a<3; a++)
{
printf("\nPlease enter name %d : ", a+1);
scanf("%s", name[a]);
printf(" Please enter %s's age : ", name[a]);
scanf("%d", &age[a]);
}
printf("\nSecond record is : %s and %d years old", name[1], age[1]);
return 0;
}

原帖由 无我不在 于 2009-1-11 04:08 PM 发表
这个列子回要求重复input。到了第四次input才会结束for loop的。
我的作业要求输入一次资料后回到menu,然后再做选择。然而,第二次输入资料,可以自动地记入另一个空间。最后,客户以IC搜索(strcmp),找回 ...
JBTALKS.CC |联系我们 |隐私政策 |Share
GMT+8, 2025-10-27 12:21 AM , Processed in 0.106730 second(s), 24 queries .
Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
Dedicated Server powered by iCore Technology Sdn. Bhd.