?? ch04_21.c
字號:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char select;
int g_num;
double total, amount, discount;
printf("請輸入購買的商品代碼x(電冰箱),y(冷氣機),z(個人計算機):");
scanf("%c", &select); /*輸入字符并存入變量select*/
printf("請輸入購買數(shù)量:");
scanf("%d", &g_num); /*輸入字符并存入變量select*/
printf("---------------------------------------\n");
switch(select)
{
case 'x':
case 'X': /*如果select等于'x'或'X'*/
total=10000*g_num; /*則計算電冰箱單價*購買數(shù)量*/
break; /*跳出switch*/
case 'y':
case 'Y': /*如果select等于'y'或'Y'*/
total=15000*g_num; /*則計算冷氣機單價*購買數(shù)量*/
break; /*跳出switch*/
case 'z':
case 'Z': /*如果select等于'z'或'Z'*/
total=25000*g_num; /*則計算個人計算機單價*購買數(shù)量*/
break; /*跳出switch*/
}
if (total>=100000) /*如果購買金額超過150000*/
discount=total*0.15; /*則15%折扣*/
else if (total>=50000) /*如果購買金額超過50000*/
discount=total*0.1; /*則10%折扣*/
else /*低于50000*/
discount=total*0.05; /*則5%折扣*/
amount=total-discount; /*折扣后金額=總金額-折扣*/
printf("總購買金額為: %.2f\n", total);
printf("折扣金額為: %.2f\n", discount);
printf("應(yīng)付金額為: %.2f\n", amount);
system("pause");
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -