Implementing a tool that is able to match the sum of Due Payments with the corresponding Bank Transfer.
The solution can be divided in three steps:
- readInputFile : reading file whose name is inserted from command line. It returns the list of Due Payments and the Bank Transfer.
- searchAmount: method returning the list of Due Payments corresponding with the Bank Transfer amount.
- writeFile: method that writes the list of Due Payments in the output file.
The solution consists in a recursive algorithm whose scope is looking for the right number of Due Payments matching with the Bank Transfer amount. For each node the algorithm sums up the i-th due payment. If the sum is bigger than the expected one, the algorithms goes back recursively to the previous step and will continue to search for the next ith+1 due payment. The algorithm will stop its execution in two cases:
- The reached sum correspond with the Bank Transfer amount.
- All the possible solutions have been visited; in this case the output file will contain the string “No Solution”.
The behaviour of the algorithm is shown graphically:
Clone the repository and open it in a VisualStudio IDE.