summaryrefslogtreecommitdiff
path: root/3.1-v3.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3.1-v3.cpp')
-rw-r--r--3.1-v3.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/3.1-v3.cpp b/3.1-v3.cpp
new file mode 100644
index 0000000..4457731
--- /dev/null
+++ b/3.1-v3.cpp
@@ -0,0 +1,32 @@
+#include <iostream>
+#include "sales_data.hpp"
+
+/*
+ *
+ * 2.41 - 1.22
+ *
+ *
+ */
+using std::cout;
+using std::cin;
+using std::endl;
+int main () {
+
+ SalesData book1;
+ SalesData Sum;
+ if(cin >> Sum.BookNo >> Sum.UnitsSold >> Sum.Revenue) {
+ while(cin >> book1.BookNo >> book1.UnitsSold >> book1.Revenue) {
+ if(Sum.BookNo == book1.BookNo) {
+ Sum.UnitsSold += book1.UnitsSold;
+ Sum.Revenue += book1.Revenue;
+ } else {
+ cout << "These books do not have the same ISBN" << endl;
+ return -1;
+ }
+ }
+ }
+
+ cout << Sum.BookNo << " " << Sum.UnitsSold << " " << Sum.Revenue << endl;
+
+ return 0;
+}