首页 > 代码库 > UT源码162

UT源码162

(3)设计佣金问题的程序

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)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _03
{
    class Program
    {
        public static void put()
        {
            Console.WriteLine("请输入耳机的销售情况:");
            int H = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入手机壳的销售情况:");
            int S = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入手机贴膜的销售情况:");
            int P = int.Parse(Console.ReadLine());
            Commission(H, S, P);
        }
        static void Main(string[] args)
        {
            put();
            Console.ReadKey();
        }
        public static void Commission(int Headphone,int Shell,int Protect)
        {
            double AllMony = 80 * Headphone + 10 * Shell + 8 * Protect;
            double Yongjin = 0;
           
            if (AllMony < 1000&&AllMony>0)
            {
                Yongjin = AllMony * 0.1;
                Console.WriteLine("本次销售后所得佣金为:"+Yongjin);
                put();
            }
            else if (AllMony >= 1000 && AllMony <= 1800)
            {
                Yongjin = 100 + (AllMony - 1000) * 0.15;
                Console.WriteLine("本次销售后所得佣金为:"+Yongjin);
                put();
            }
            else if (AllMony > 1800)
            {
                Yongjin = (100 + (AllMony - 1000) * 0.15) + (AllMony - 1800) * 0.2;
                Console.WriteLine("本次销售后所得佣金为:"+Yongjin);
                put();
            }
            else
            {
                Console.WriteLine("输入的数量不符合要求,请重新输入!");
                put();
            }
           
           
        }
    }
}

UT源码162