zoukankan      html  css  js  c++  java
  • UT源码 063

    设计佣金问题的程序

    commission方法是用来计算销售佣金的需求,手机配件的销售商,手机配件有耳机(headphone)、手机壳(Mobile phone shell)、手机贴膜(Cellphone screen protector)三个部件,每个部件单价为:耳机80元,手机壳10元,手机贴膜8元,每月月末向制造商报告销量,制造商根据销量给销售商佣金。如果销售额不足1000元按10%提取佣金,1000-1800元部分按15%提取佣金,超过1800元部分按20%提取佣金。

    程序要求:

    1)先显示“请分别输入三种手机配件的销售情况:”

    2)不满足条件,返回:“输入数量不满足要求”,返回重新输入;

    3)条件均满足, 则返回佣金额。返回等待输入。

    float  commission (int headphone, int shell, int protector)

    #include"cstdio"
    #include"iostream"
    #include"algorithm"
    #include"cstring"
    #include"cmath"
    using namespace std;
    float commission(int headphone, int shell, int protector)
    {
        if(headphone<0 || shell<0 || protector<0)
            return -1.0f;
        long long sum=80*(long long)headphone + 10*(long long)shell + 8*(long long)protector;
        float ans=0.0f;
        if(sum<1000)
            ans=sum*0.1f;
        else if(sum>=1000 && sum<=1800)
            ans=100.0f+(sum-1000)*0.15f;
        else
            ans=(sum-1800.0)*0.2+220.0;
        return ans;
    }
    int main()
    {
        while(1)
        {
            int HP;//耳机
            int MPS;//手机壳
            int CSP;//手机贴膜 
            printf("请分别输入三种手机配件的销售情况(按耳机、手机壳、手机贴膜顺序,空格隔开):
    ");
            scanf("%d",&HP);
            scanf("%d",&MPS);
            scanf("%d",&CSP);
            float ans=commission(HP,MPS,CSP);
            if(fabs(ans+1.0f)<=0.000000001) 
            {
                printf("输入数量不满足要求
    
    ");
                continue;
            }
            else
                printf("佣金金额:%.2f元
    
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    简单复利计算java板
    弹出提示框的方式——java
    实验一 命令解释程序
    简单复利计算c语言实现
    操作系统
    jsp 页面和 jsp标记
    对it行业的一些看法
    又穷自动机的构造
    复利计算——结对编程2.0
    汉堡包
  • 原文地址:https://www.cnblogs.com/ChainYugi/p/6530151.html
Copyright © 2011-2022 走看看