我是靠谱客的博主 尊敬皮卡丘,这篇文章主要介绍以下是用C语言编写的计算购买图书金额的程序,现在分享给大家,希望可以做个参考。

#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语言编写内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部