zoukankan      html  css  js  c++  java
  • 7.12.11 蔬菜计算器

    # 7.12.11
    #include <stdio.h>
    #define artichoke 2.05
    #define beet	  1.15
    #define carrot	  1.09
    #define discount  0.95
    int main(void)
    {
        double partichoke, sum_artichoke_pound = 0;
        double pbeet, sum_beet_pound = 0;
        double pcarrot, sum_carrot_pound = 0;
        double total, sum_pound, vegetable_total, ori_vegetable_total, Freight_packing_fee, saveoff;
        char ch;
    
        printf("a.artichoke is %f
    ", artichoke);
        printf("b.beet is %f
    ", beet);
        printf("c.carrot is %f
    ", carrot);
        printf("q is quit!
    ");
        while ((ch = getchar()) != 'q')
        {
            switch (ch)
            {
                case 'a':
                    {
                    printf("Please artichoke pound is ");
                    scanf("%lf", &partichoke);
                    printf("partichoke is %f
    ", partichoke);
                    sum_artichoke_pound += partichoke;
                    printf("sum_artichoke_pound is %f
    ", sum_artichoke_pound);
                    break;
                    }
                case 'b':
                    {
                    printf("Please beet pound is ");
                    scanf("%lf", &pbeet);
                    printf("pbeet is %f
    ", pbeet);
                    sum_beet_pound += pbeet;
                    printf("sum_beet_pound is %f
    ", sum_beet_pound);
                    break;
                    }
                case 'c':
                    {
                    printf("Please carrot pound is ");
                    scanf("%lf", &pcarrot);
                    printf("pcarrot is %f
    ", pcarrot);
                    sum_carrot_pound += pcarrot;
                    printf("sum_carrot_pound is %f
    ", sum_carrot_pound);
                    break;
                    }
                case 'q':
                    break;
            }
        printf("1a.artichoke is %f
    ", artichoke);
        printf("2b.beet is %f
    ", beet);
        printf("3c.carrot is %f
    ", carrot);
        printf("4q is quit!
    ");
            if ((ch = getchar()) == '
    ');
        }
    
        ori_vegetable_total = vegetable_total = artichoke * sum_artichoke_pound + beet * sum_beet_pound + carrot * sum_carrot_pound;   // 货物总价 蔬菜总价
        if (vegetable_total > (double)100)
        {
            saveoff = vegetable_total * (1.0 - discount);
            vegetable_total *= discount;
        }
    
        sum_pound = sum_artichoke_pound + sum_beet_pound + sum_carrot_pound;
        if (sum_pound <= (double)5)
        {
            total = vegetable_total + 6.5;
            Freight_packing_fee = 6.5;
        }
        else if ((sum_pound > (double)5) && (sum_pound <= (double)20))
        {
            total = vegetable_total + (double)14;
            Freight_packing_fee = 14.0;
        }
        else if (sum_pound > (double)20)
        {
            total = vegetable_total + (double)14 + (sum_pound - (double)20) * 0.5;
            Freight_packing_fee = (double)14 + (sum_pound - (double)20) * 0.5;
        }
    
        printf("货物总价是 %.2f
    ", vegetable_total);
        printf("折扣是 %.2lf
    ", saveoff);
        printf("运费包装费是 %.2f", Freight_packing_fee);
    
        printf("购买信息如下
    ");
        printf("artichoke is %lf, pound is %lf
    ", artichoke, sum_artichoke_pound);
        printf("beet is %lf, pound is %lf
    ", beet, sum_beet_pound);
        printf("carrot is %lf, pound is %lf
    ", carrot, sum_carrot_pound);
        printf("订购蔬菜费用是 %.2lf
    ", ori_vegetable_total);
        printf("订单总费用是 %.2lf
    ", total);
        printf("折扣是 %.2lf
    ", saveoff);
        printf("运费包装费是 %.2lf
    ", Freight_packing_fee);
    
        return 0;
    }
    

  • 相关阅读:
    微信公众号,图片预览功能 有单个图片,
    MUI
    MUI学习01-顶部导航栏
    php验证18位身份证,准到必须输入正确的身份证号,
    微信sdk 图片上传 两种方法 上传一张显示一张 并附带微信图片放大功能和删除功能
    jQuery实现限制input框 textarea文本框输入字符数量的方法
    js jq 手机号实现(344) 附带删除功能 jq 实现银行卡没四个数加一个空格 附带删除功能
    山东省2016acm省赛
    East Central North America Region 2015
    North America Qualifier (2015)
  • 原文地址:https://www.cnblogs.com/EisNULL/p/10839954.html
Copyright © 2011-2022 走看看