summaryrefslogtreecommitdiff
path: root/2.42-v3.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-08-03 22:51:15 +0200
committerOskar <[email protected]>2024-08-03 22:51:15 +0200
commit1d105b91b9678ffaa8eddea2218ed1789f5be27c (patch)
tree89563fd6bcbe5411b244ac361098fbdddc321f5f /2.42-v3.cpp
parent0de72ab100011ab54f99f298e936327011ebc706 (diff)
more assignments
Diffstat (limited to '2.42-v3.cpp')
-rw-r--r--2.42-v3.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/2.42-v3.cpp b/2.42-v3.cpp
new file mode 100644
index 0000000..bc16fff
--- /dev/null
+++ b/2.42-v3.cpp
@@ -0,0 +1,30 @@
+#include <iostream>
+#include "sales_data.hpp"
+
+/*
+ *
+ * 2.41 - 1.22
+ *
+ *
+ */
+
+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;
+}