原帖由 无我不在 于 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),找回 ...
原帖由 Super-Tomato 于 2009-1-11 05:06 PM 发表
switch(choice)
{
case 'A':
case 'a':
printf("Please enter name %i : ", i+1);
scanf("%s", name[ i ]);
printf("Please enter %s's age : ", name);
scanf("%i", &age[ i ]);
i++;
break;
}
原帖由 无我不在 于 2009-1-11 05:52 PM 发表
是不是在case ‘C’ 出现问题?还是在case 'B'的算术中的variable不能存储之前的资料?因为只能出现最后一次的资料。
case 'C' : printf("Enter Your NRIC: ");
flushall();
gets(icno_search);
if(strcmp(icno[a], icno_search) == 0)
{
printf("\n\nYour Total Amount Payment");
printf("\n=========================");
printf("\nNRIC\t\t\t : %s", icno[a]);
printf("\nName\t\t\t : %s", name[a]);
printf("\nDate of Brith\t\t : %s\n", DOB[a]);
printf("Sex\t\t\t : %c\n\n", sex[a]);
printf("Total income\t\t : $%9.2f\n", total_income[a]);
printf("\t\tLess relief: -$%9.2f\n", total_relief[a]);
printf("Total taxable amount\t : $%9.2f\n", taxable_amount[a]);
printf("\t\tLess rebate: -$%9.2f\n", total_rebate[a]);
printf("\n");
printf("Amount payment\t\t : $%9.2f\n", amount_payment[a]);
}
printf("\n");
printf("**If you don't use this Tax Advisor Program, please press D to QUIT.\n\n\n");
break;
原帖由 无我不在 于 2009-1-16 09:56 PM 发表
进入Z case,系统要求:
PASSWORD: 123456
在switch_case Z那里,我想增加一个效果。就是当你输入PASSWORD时,如何隐藏PASSWORD?比如说,
进入Z case,
PASSWORD:****** // input 改为*码
...
原帖由 无我不在 于 2009-1-17 09:47 AM 发表
case 'z' :
case 'Z' : while(ch != '\r') //\r是什么?
{
ch = getch();
cerr<<"*"; //cerr是什么?需要declare吗?
stuff_password[i++] = ch;
printf("\n\tPassword: ");
gets(stuff_password);
}
原帖由 无我不在 于 2009-1-17 12:52 PM 发表
【成功运行】
我的visual 2008不能用iostream叻。
所以我用这个function。可是不好写……
参考:http://hi.baidu.com/toyourside/b ... 56088f47106493.html
char* get_password(const ...
原帖由 无我不在 于 2009-1-17 11:37 PM 发表
其实我学校教的很有限。
现在都是自己在爬文章和例子。基础也不稳。
每次我开的coding都是属于 .c file(学校教的)来的。这样是不是会影响到我不能用iostream呢?因为我拷贝你的coding,都不能运行。还是要 ...
原帖由 无我不在 于 2009-1-23 11:01 PM 发表
应用: 2D Array in password setting with display '*' sign. (.c language only)
状况:通常在网路申请新户口时,官方会要求设定密码,同时要求输入多一回以确定你的密码。如果不相同,系统要求重新输入。 ...
欢迎光临 JBTALKS.CC (https://jbtalks.my/) | Powered by Discuz! X2.5 |