#include<iostream>
using?namespace?std;
class?shop
{
public:
shop(int?q=0,double?p=0):quantity(q),price(p){}; void?total(); static?float?average(); static?float?sum;private:
int?quantity; double?price; static?double?discount; static?int?n;};
void?shop::total()
{
int?rate=1.0; if(quantity>=10)rate=0.98*rate; sum=sum+price*rate*discount*quantity; n=n+quantity;}
float?shop::average()
{
return(sum/n);}
double?shop::discount=0.9;
float?shop::sum=0;
int?shop::n=0;
int?main()
{
shop?s[3]={shop(5,23.5),
shop(12,24.56),
shop(100,21.5)};
int?i;
for(i=0;i<3;i++)
s[i].total();
cout<<"總價是"<<shop::sum<<endl;
cout<<"單價是"<<shop::average()<<endl;
return?0;
}