- 分享
- 0
- 人气
- 0
- 主题
- 7
- 帖子
- 4707
- UID
- 82675
- 积分
- 5108
- 阅读权限
- 22
- 注册时间
- 2007-6-18
- 最后登录
- 2021-7-27
- 在线时间
- 5767 小时
|
原帖由 无我不在 于 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");
}
因為你所訂的 name 是 2 dimension, 而你所 gets 的卻是 1 dimension, 所以不能被儲存 |
|