blob: 95af90219c0c0cca96fa0d6a42b158c4c840f717 (
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.22
*
*
*/
struct SalesData {
std::string BookNo;
unsigned int UnitsSold = 0;
double Revenue = 0.0;
};
int main () {
SalesData book1;
SalesData Sum;
if(std::cin >> Sum.BookNo >> Sum.UnitsSold >> Sum.Revenue) {
while(std::cin >> book1.BookNo >> book1.UnitsSold >> book1.Revenue) {
if(Sum.BookNo == book1.BookNo) {
Sum.UnitsSold += book1.UnitsSold;
Sum.Revenue += book1.Revenue;
} else {
std::cout << "These books do not have the same ISBN" << std::endl;
return -1;
}
}
}
std::cout << Sum.BookNo << " " << Sum.UnitsSold << " " << Sum.Revenue << std::endl;
return 0;
}
|