99问答网
所有问题
【C语言编程】航空公司托运行李规定,行李重量不超过10公斤的,托运费按每公斤15元计费
超过的话,超过部分每公斤加收10元。编写一个程序完成计费工作。
举报该问题
推荐答案 2022-12-04
#include\x0d\x0aint main()\x0d\x0a{\x0d\x0adouble baggage;\x0d\x0adouble cost;\x0d\x0aprintf("请输入行李的重量:");\x0d\x0ascanf("%lf",&baggage);\x0d\x0aif(baggage>10)\x0d\x0acost=10*15+(baggage-10)*10; \x0d\x0aelse\x0d\x0acost=baggage*15;\x0d\x0aprintf("行李托运费为:cost=%.4lf\n",cost); //精确到小数点后4位\x0d\x0areturn 0;\x0d\x0a\x0d\x0a}
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://99.wendadaohang.com/zd/WjjevXXvtzjzvjztvvX.html
其他回答
第1个回答 推荐于2019-10-17
#include<
stdio.h
>
int main()
{
double baggage;
double cost;
printf("请输入行李的重量:");
scanf("%lf",&baggage);
if(baggage>10)
cost=10*15+(baggage-10)*10;
else
cost=baggage*15;
printf("行李托运费为:cost=%.4lf\n",cost); //精确到小数点后4位
return 0;
}
本回答被网友采纳
相似回答
大家正在搜
相关问题
【C语言编程】航空公司托运行李规定,行李重量不超过10公斤的...
国内所有航空公司托运行李都不能超过10公斤吗?
机场托运重量是不是算超出10公斤的?
飞机上携带行李的重量上限是多少?
我买了西部航空的票,说可以托运10公斤行李,我带20公斤付费...
坐飞机超过托运规定重量怎么办
重庆江北机场的行李托运规定,是不是可以免费的托运20kg的行...