summaryrefslogtreecommitdiff
path: root/2p41-1p23-1p24.cpp
blob: 0f5576137606c7984dd363cc8031c987a15e2bb3 (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
33
34
35
36
#include <iostream>
#include "sales_item.hpp"

/*
 *
 * 2.41 - 1.23 - 1.24
 *
 *
 */

struct SalesData {
	std::string BookNo;
	unsigned int UnitsSold = 0;
	double Revenue = 0.0;
};

int main () {

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

	return 0;
}