summaryrefslogtreecommitdiff
path: root/3.1-v4.cpp
blob: df74ddb20264401d77ae7b3979ec33792ce3b7ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include "sales_data.hpp"

/*
 *
 * 2.41 - 1.23 - 1.24
 *
 *
 */
using std::cout;
using std::cin;
using std::endl;
int main () {

	SalesData Item;
	SalesData CurItem;	
	if(cin >> CurItem.BookNo >> CurItem.UnitsSold >> CurItem.Revenue) {
		unsigned int Count = CurItem.UnitsSold;
		while(cin >> Item.BookNo >> Item.UnitsSold >> Item.Revenue) {
			if(Item.BookNo == CurItem.BookNo) {
				Count += Item.UnitsSold;
			} else {
				cout << "ISBN: " << CurItem.BookNo << " has " << Count << " transactions" << endl;
				CurItem = Item;
				Count = Item.UnitsSold;
			}
		}
		cout << "ISBN: " << CurItem.BookNo << " has " << Count << " transactions" << endl;
	}

	return 0;
}