第三章第九题
来源:互联网 发布:补丁软件 编辑:程序博客网 时间:2024/06/05 18:09
#include <iostream>
using namespace std;
class Product
{public:
Product(int n,int q,float p):num(n),quantity(q),price(p){};
void total();
static float average();
static void display();
private:
int num;
int quantity;
float price;
static float discount;
static float sum;
static int n;
};
void Product::total()
{float rate=1.0;
if(quantity>10) rate=0.98*rate;
sum=sum+quantity*price*rate*(1-discount);
n=n+quantity;
}
void Product::display()
{cout<<sum<<endl;
cout<<average()<<endl;
}
float Product::average()
{return(sum/n);}
float Product::discount=0.05;
float Product::sum=0;
int Product::n=0;
int main()
{
Product Prod[3]={
Product(101,5,23.5),Product(102,12,24.56),Product(103,100,21.5)
};
for(int i=0;i<3;i++)
Prod[i].total();
Product::display();
return 0;
}
- 第九章第三题
- 第三章第九题
- 第三章第九题
- ibmMQ第三部分第九章
- 第三届蓝桥杯第九题 足球比赛
- 记录——《C Primer Plus (第五版)》第九章编程练习第三题
- 剑指offer第三题至第九题(java详解)
- C++ primer 中文第三版 阅读笔记 第九、十章
- Java 线程第三版 第九章 Thread调度 读书笔记
- Core java 第九版第三章基本程序结构
- 第三届蓝桥杯预赛第九题——趣味算式
- 第三届蓝桥杯C/C++组第九题 足球比赛(概率论+随机数)
- 第九届CCF CSP认证 第三题:权限查询
- CCF第九次认证第三题权限查询参考答案
- 第九章 二题
- 第九章第二题
- 第二章第九题
- 第二章第九题
- 防火墙、网关、路由器
- 马云逼问王健林:万达做O2O想付出多大代价?
- UDP broadcast package on win7
- 第三章 第3题
- 算法复习--------------基本算法:间接寻址的实现
- 第三章第九题
- todo list
- sap 去前置0
- Oracle trunc()函数的用法
- 思维模式-随笔
- linux应用开发-gdb调试
- Struts2入门教程-Hello World!
- 黑马程序员————OC内存管理_笔记整理(二)
- 第三章第十题