含む
/* 関数プロトタイプの宣言 */
float Calculate_Duty (int, int);
void Print_Duty (float);
int main (空)
{
/* プログラムで使用するすべての変数を宣言します */
char more_to_process;
int 原産地、カテゴリ、数量、num_ship=0;
float unit_price;
フロートコスト、関税、total_ship=0;
float total_duty=0, tax_rate=0;
/* プログラムの実行を開始します */
printf("処理する税関申告書が他にありますか? タイプ: はいの場合は Y、いいえの場合は N \n");
scanf(" %c", &more_to_process);
while ((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", &数量);
printf ("単価はいくらですか? \n");
scanf ("%f", &unit_price);
total_ship= 数量 * unit_price;
/* 出荷の関税を計算します */
tax_rate= Calculate_Duty (原産地、カテゴリー);
関税=税率*合計船;
total_duty+= 義務;
/* 貨物の関税を出力 */
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", origin,
カテゴリ、数量、unit_price、total_ship、tax_rate、duty);
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 原点、int カテゴリ)
{
フロート義務;
スイッチ(原点)
{
/* ケース 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", 関税);
}