第9题
来源:互联网 发布:睡衣推荐 知乎 编辑:程序博客网 时间:2024/06/07 01:15
#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; }
0 0
- 第1章 第9题
- 第3章 第9题
- 第5章 第9题
- 第5章第9题
- P51 第9题
- 第一章第9题
- p51第9题
- 第9题
- 算法第9题
- 第9题
- 第9题
- 第9题
- 第9题
- c++第9题
- PythonChallenge第9题
- 第一章第9题
- 第9题
- leecode第9题
- 搜索- poj2965 The Pilots Brothers' refrigerator
- KMP
- Activity真正显示后回调onPostCreate方法
- ResourceType Style contains key with bad entry:0x01010479
- javascript基础总结(五)--闭包
- 第9题
- linux下IDE硬盘序列号的获取方法
- 从头到尾彻底理解KMP
- Android进程间通信 AIDL学习资料
- 移动支付漫谈
- Android Studio使用教程(一)
- Android 屏幕适配(英文版)20150420日更新
- iOS网络请求总结
- 第二章第4题