#include
using namespace std;
class sale
{public:
sale(int,int,float);
static float average();
static void display();
private:
int num;
int quantity;
float price;
int s;
static float sum;
static float discount;
static int n;
};

sale::sale(int nu,int q,float p)
{num = nu;
quantity = q;
price = p;
n += q;
if(q <= 10)
{s = p q discount;
sum = sum + s;
}
else
{s = p q discount * 0.98;
sum = sum + s;
}
}

float sale::average()
{return (sum/n);
}

void sale::display()
{cout<<"总销售额"<cout<<"平均售价"<}
float sale::discount = 0.95;
float sale::sum = 0;
int sale::n = 0;

int main()
{sale a(101,5,23.5),b(102,12,24.56),c(103,100,21.5);
sale::display();
return 0;
}一个C++程序_第1张图片