summaryrefslogtreecommitdiff
path: root/7p3.cpp
blob: 81129f65260b16c0c96dc87808f33f3e6df7a93f (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_data.hpp"

/*
 *
 * 7.3
 *
 * This exercise is not correct and honestly i am not sure
 * what is supposed to be correct. It may be because i misunderstood
 * The exercise back in the 1.24 exercise.
 *
 * I have modified this program now to be more like i think it should be...
 */

int main () {

	
	SalesData CurItem;	
	if(std::cin >> CurItem.BookNo >> CurItem.UnitsSold >> CurItem.Revenue) {
		SalesData Item;
		while(std::cin >> Item.BookNo >> Item.UnitsSold >> Item.Revenue) {
			if(Item.isbn() == CurItem.isbn()) {
				CurItem.combine(Item);
			} else {
				std::cout << "ISBN: " << CurItem.BookNo << " has " << CurItem.UnitsSold << " units sold"
						  << " and a revenue of: " << CurItem.Revenue << std::endl;
				CurItem = Item;
			}
		}
		
		std::cout << "ISBN: " << CurItem.BookNo << " has " << CurItem.UnitsSold << " units sold"
						  << " and a revenue of: " << CurItem.Revenue << std::endl;
	}

	return 0;
}