标签:tor miss name 部件 cell float names class namespace
设计佣金问题的程序
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)
源码:
1 #include "stdafx.h" 2 #include "iostream" 3 using namespace std; 4 float commission(int headphone, int shell, int protector) 5 { 6 float paymoney; 7 int total = headphone * 80 + shell * 10 + protector * 8; 8 if (headphone < 0 || shell < 0 || protector < 0) 9 { 10 cout << "输入数量不满足要求”,返回重新输入"; 11 } 12 else if (total < 1000) 13 { 14 paymoney = total*0.1; 15 cout << "佣金为:" << paymoney; 16 } 17 else if (total >= 1000 && total <=1800) 18 { 19 paymoney = (total - 1000)*0.15 + 100; 20 cout << "佣金为:" << paymoney; 21 } 22 else if (total>1800) 23 { 24 paymoney = (total - 1800)*0.2 + 220; 25 cout << "佣金为:" << paymoney; 26 } 27 return paymoney; 28 } 29 int _tmain(int argc, _TCHAR* argv[]) 30 { 31 while (1) 32 { 33 cout << "请分别输入三种手机配件的销售情况:" << endl; 34 int headphone, shell, protector; 35 cin >> headphone >> shell >> protector; 36 commission(headphone, shell, protector); 37 system("pause"); 38 } 39 }
标签:tor miss name 部件 cell float names class namespace
原文地址:http://www.cnblogs.com/cjccjc/p/6530603.html