summaryrefslogtreecommitdiff
path: root/2p41-1p21-v2.cpp
blob: 248a059d22e56e9922fd18334dfedcd54d19297d (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.21
 *
 *
 */

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

int main () {
	
	SalesData book1;
	SalesData book2;
	if(std::cin >> book1.BookNo >> book1.UnitsSold >> book1.Revenue) {
		while(std::cin >> book2.BookNo >> book2.UnitsSold >> book2.Revenue) {
			if(book1.BookNo != book2.BookNo) {
				std::cout << "These books do not have the same ISBN" << std::endl;
				continue;
			}
			
			std::cout << book1.BookNo << " " << book1.UnitsSold + book2.UnitsSold << " " << book1.Revenue + book2.Revenue << std::endl;
		}
	} else {
		std::cout << "Error!" << std::endl;
		return -1;
	}
	
	return 0;
}