diff options
author | Oskar <[email protected]> | 2024-08-03 22:51:15 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-08-03 22:51:15 +0200 |
commit | 1d105b91b9678ffaa8eddea2218ed1789f5be27c (patch) | |
tree | 89563fd6bcbe5411b244ac361098fbdddc321f5f /2p41-1p23-1p24.cpp | |
parent | 0de72ab100011ab54f99f298e936327011ebc706 (diff) |
more assignments
Diffstat (limited to '2p41-1p23-1p24.cpp')
-rw-r--r-- | 2p41-1p23-1p24.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/2p41-1p23-1p24.cpp b/2p41-1p23-1p24.cpp new file mode 100644 index 0000000..0f55761 --- /dev/null +++ b/2p41-1p23-1p24.cpp @@ -0,0 +1,36 @@ +#include <iostream> +#include "sales_item.hpp" + +/* + * + * 2.41 - 1.23 - 1.24 + * + * + */ + +struct SalesData { + std::string BookNo; + unsigned int UnitsSold = 0; + double Revenue = 0.0; +}; + +int main () { + + SalesData Item; + SalesData CurItem; + if(std::cin >> CurItem.BookNo >> CurItem.UnitsSold >> CurItem.Revenue) { + unsigned int Count = CurItem.UnitsSold; + while(std::cin >> Item.BookNo >> Item.UnitsSold >> Item.Revenue) { + if(Item.BookNo == CurItem.BookNo) { + Count += Item.UnitsSold; + } else { + std::cout << "ISBN: " << CurItem.BookNo << " has " << Count << " transactions" << std::endl; + CurItem = Item; + Count = Item.UnitsSold; + } + } + std::cout << "ISBN: " << CurItem.BookNo << " has " << Count << " transactions" << std::endl; + } + + return 0; +} |