商店销售某一商品,商店每天公布统一的折扣(discount)
2011-04-11 11:01
671 查看
商店销售某一商品,商店每天公布统一的折扣(discount)。同时允许销售人员
在销售时灵活掌握售价(price),在此基础上,对一此购10件以上者,还可以享受9.8折优惠,现已知当天3名销售员销售情况为:
售货员号(num) 售货件数(quantity)售货单价(price)
101 5 23.5
102 12 24.56
103 100 21.5
#include<iostream>
using namespace std;
class Shop
{
public:
Shop(int m,int q,float p):num(m),quantity(q),price(p){};
void zongjia();
static float average();
static void display();
private:
int num;//人员号码
int quantity;//件数
float price;//单价
static float discount;//每天折扣
static float sum;//总金额
static int n;//总件数
};
void Shop::zongjia()
{
float rate=1.0;
if(quantity>10)rate=0.98*rate;
sum=sum+quantity*price*rate*(1-discount);
n=n+quantity;
}
void Shop::display()
{
cout<<sum<<endl;
cout<<average()<<endl;
}
float Shop::average()
{
return (sum/n);
}
float Shop::discount=0.05;
float Shop::sum=0;
int Shop::n=0;
int main ()
{
Shop s[3]={
Shop(101,5,23.5),
Shop(102,12,24.56),
Shop(103,100,21.5)
};
int i;
for(i=0;i<3;i++)
s[i].zongjia();
Shop::display();
return 0;
}
在销售时灵活掌握售价(price),在此基础上,对一此购10件以上者,还可以享受9.8折优惠,现已知当天3名销售员销售情况为:
售货员号(num) 售货件数(quantity)售货单价(price)
101 5 23.5
102 12 24.56
103 100 21.5
#include<iostream>
using namespace std;
class Shop
{
public:
Shop(int m,int q,float p):num(m),quantity(q),price(p){};
void zongjia();
static float average();
static void display();
private:
int num;//人员号码
int quantity;//件数
float price;//单价
static float discount;//每天折扣
static float sum;//总金额
static int n;//总件数
};
void Shop::zongjia()
{
float rate=1.0;
if(quantity>10)rate=0.98*rate;
sum=sum+quantity*price*rate*(1-discount);
n=n+quantity;
}
void Shop::display()
{
cout<<sum<<endl;
cout<<average()<<endl;
}
float Shop::average()
{
return (sum/n);
}
float Shop::discount=0.05;
float Shop::sum=0;
int Shop::n=0;
int main ()
{
Shop s[3]={
Shop(101,5,23.5),
Shop(102,12,24.56),
Shop(103,100,21.5)
};
int i;
for(i=0;i<3;i++)
s[i].zongjia();
Shop::display();
return 0;
}
相关文章推荐
- Chapter9——商店销售某一商品,每天公布统一的折扣(discount)。
- 商店销售某一商品,商店每天公布统一的折扣(discount)
- 商店销售某一商品,商店每天公布统一的折扣(第三章第9题)
- 商店销售统计,每天有一个折扣价格,一次购10件以上者可以享受9.8折优惠,已知三个销售员的销售情况,运用静态数据成员和静态成员函数编写程序
- 简单统计商店某商品销售情况
- 中普商品报价销售系统 v3.01 是什么
- △【OJ】---N---商品销售
- 简易商品销售
- 北京市限价商品住房管理办法(试行)公布
- 商品销售打折自定义的数据建模
- Java 基础代码实例 :判断顾客对商品折扣的反应情况。
- [YTU]_2434 ( C++习题 商品销售)
- 谷歌推出新数字商店 销售以云计算为基础软件
- 发票识别/机动车销售统一发票识别管理方案
- 某超市商品销售情况
- 用sql做apriori商品关联销售分析
- Magento给产品添加“new”或者折扣数量标签 magento new label. discount label
- mssql将传入的文本信息写入临时表,记录之间通过';'进行分割,商品编码,数量,销售金额通过','进行分割
- 获得当前分类ID,产品详细信息页面得到当前产品默认商店的的商品名称