包括
/* 声明函数原型 */
float Calculate_Duty (int, int);
无效 Print_Duty(浮点数);
int 主要(无效)
{
/* 声明程序中要使用的所有变量 */
char more_to_process;
int 原产地、类别、数量、num_ship=0;
浮动单位价格;
浮动成本,关税,total_ship=0;
浮动total_duty=0,tax_rate=0;
/* 开始执行程序 */
printf("您还有更多海关表格要处理吗?输入:Y 表示是或 N 表示否 \n");
scanf("%c", &more_to_process);
而 ((more_to_process =='Y') && (more_to_process!='N'))
{
printf("货物的原产地是什么?类型:1代表美国,2代表中国,3代表巴西\n");
scanf ("%d", &origin);
printf("什么类别的商品?类型:1食品,2衣服,3木材\n");
scanf ("%d", &category);
printf("数量是多少?\n");
scanf ("%d", &quantity);
printf("单价是多少?\n");
scanf ("%f", &unit_price);
total_ship=数量*单价;
/* 计算货物的关税 */
tax_rate=Calculate_Duty(来源,类别);
关税= tax_rate * total_ship;
总职责+=职责;
/* 打印货物的关税 */
printf("产地\t类别\t数量\t单价\t出货\t税率\t关税\t\n");
printf ("%d \t %d \t \t %d \t \t %02.f \t \t %0.2f \t %0.2f \t \t %0.2f \t \n", 原点,
类别、数量、单价、总船、税率、关税);
Print_Duty(职责);
printf ("您还有更多的海关表格要处理吗?类型:Y 表示是,N 表示否\n");
scanf (" %c", &more_to_process);
++num_ship;
}
printf("事务摘要:\n");
printf ("处理的货件数量 = %d \n", num_ship);
printf ("收集的总职责 = $ %0.2f \n", total_duty);
返回0;
}
/* 执行函数Calculate_Duty */
float Calculate_Duty (int origin, int category)
{
浮动税;
开关(原点)
{
/* 案例 1 适用于美国 */
情况1:
开关(类别)
{
情况1:
职责=0;
休息;
案例2:
职责= 0;
休息;
案例3:
职责= .05;
休息;
}
休息;
/* 案例 2 适用于中国 */
案例2:
开关(类别)
{
情况1:
职责= .02;
休息;
案例2:
职责= .03;
休息;
案例3:
职责= .04;
休息;
}
休息;
/* 案例 3 适用于巴西 */
案例3:
开关(类别)
{
情况1:
职责= .01;
休息;
案例2:
职责= .02;
休息;
案例3:
职责= .08;
休息;
}
退货税;
}
/* 执行 Print_Duty 函数 */
void Print_Duty(浮动税)
{
printf ("应付金额为 $ %0.2f \n", duty);
}