#include <stdio.h>
int main() {
float price;
int quantity;
float total;
printf("请输入图书定价:");
scanf("%f", &price);
printf("请输入图书数量:");
scanf("%d", &quantity);
if (quantity >= 100) {
total = price * quantity * 0.8;
printf("购买%d本图书,总共需要支付%.2f元n", quantity, total);
} else if (quantity >= 10) {
total = price * quantity * 0.85;
printf("购买%d本图书,总共需要支付%.2f元n", quantity, total);
} else {
total = price * quantity * 0.9;
printf("购买%d本图书,总共需要支付%.2f元n", quantity, total);
}
return 0;
}
最后
以上就是尊敬皮卡丘最近收集整理的关于以下是用C语言编写的计算购买图书金额的程序的全部内容,更多相关以下是用C语言编写内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复