Marketplace Bug Fixing

Company: Tech Mahindra_22may

Difficulty: medium

Problem Statement

Marketplace Bug Fixing Problem Description A small marketplace keeps a wallet and an inventory . The program works in three stages: The inventory is filled. Each entry adds an item name with its price. If the same name is added more than once, the later price replaces the earlier one, so every operation uses the last price added for that name. The wallet is created holding M units of money. Two workers start at the same time. The purchase worker goes through the purchase list and, for each item, takes that item's price out of the wallet. The sale worker goes through the sale list and, for each item, adds that item's price to the wallet. The original program had a bug: it read the wallet balance as soon as it had started the two workers, without waiting for them to finish, so it usually reported the starting balance. Your task is to report the correct balance: the amount in the wallet after both workers have finished every purchase and every sale . Implement handleMarket(initialMoney, i