习题 9.9 商店销售某一商品,商店每天公布统一的折扣(discount)。同时允许销售人员在销售时灵活掌握售价(price),在此基础上,对一次购10件以上者,还可以享受9.8折优惠。

习题 9.9 商店销售某一商品,商店每天公布统一的折扣(discount)。同时允许销售人员在销售时灵活掌握售价(price),在此基础上,对一次购10件以上者,还可以享受9.8折优惠。

现已知当天3名销货员的销售情况为:
   销货员号(num)    销货件数(quantity)       销货单价(price)
   101                      5                                   23.5
   102                      12                                 24.56
   103                      100                               21.5

请编程序,计算出当日此商品的总销售款sum,以及每件商品的平均售价。要求用静态数据成员和静态成员函数。

代码:

#include<iostream>
using namespace std;

class Product
{
public:
	Product(string n,int q,double p):num(n),quantity(q),price(p) {}
	static void display();
	static double average();
	void count();

private:
	string num;
	int quantity;
	double price;

	static double discount;
	static double sum;
	static int n;
};

double Product::discount = 0.98;
double Product::sum = 0.0;
int Product::n = 0;

int ma
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值