while (scanf("%d", &enter) == 1 && enter != 5)
printf("Please enter how much you earn this year:\n");
printf("Please enter how much you earn this year:\n");
printf("Please enter how much you earn this year:\n");
printf("Please enter how much you earn this year:\n");
printf("Please enter number between 1~5:\n");
printf("**************************************************\n\n");
printf("Enter the number corresponding to your status:\n");
printf("1) Single 2) House Hold\n");
printf("3) Married 4) Seprated\n");
printf("**************************************************\n\n");
printf("The tax you have to pay is $%g, and your net income is $%g\n", tax, b - tax);
tax = a * 0.15 + (b - a) * 0.28;
printf("The tax you have to pay is $%g, and your net income is $%g\n", tax, b - tax);
float pack_fee(float a, float b, float c); #注:如果要定义函数并且需要用到函数的返回值,前面一定要声明数据类型,如果不 声明会默认返回整数型。
float total_p(float a, float b, float c);
float discount(float a, float b, float c);
while (scanf("%d", &enter) == 1 && enter != 4) #注:其实这里用getchar用字符型会更好,方便操做。
printf("Enter the weight of Artichoke:\n");
printf("Enter the weight of Beet:\n");
printf("Enter the weight of Carrot:\n");
printf("Please enter number between 1~4\n");
pf = pack_fee(a, b, c); #注:需要声明一个变量去接受函数返回的值
printf("Artichoke: 2.05 $/bl Beet: 1.15 $/bl Carrot: 1.09 $/bl\n");
printf("Order detial:\n\tArtichoke\tBeet\tCarrot\n");
printf("Weight: \t%g lb \t%g lb \t%g lb\n", a, b, c);
printf("Total weight: %.2f\n", a + b + c);
printf("Price of the vegetables is %.2f\n", tp);
printf("Price include the package fee is %.2f\n", pf + tp);
printf("Discount: %%%g", dis);
printf("***********************************************************\n\n");
printf("Enter the number corresponding to the vegetable:\n");
printf("1) Artichoke 2) Beet 3) Carrot 4) Quit and Count\n");
printf("***********************************************************\n\n");
float pack_fee(float a, float b, float c)
p_fee = 6.5; #其实6.5,14等数值在头文件下面直接定义成#define会更好,方便理解和维护
else if (weight > 5 && weight <= 20)
p_fee = 14 + (weight - 20) * 0.5;
float total_p(float a, float b, float c)
cost = a * ART + b * BEET + c * CARR;
float discount(float a, float b,float c)