Question: Minimum Change Problem using Dynamic Programming and returning array of coins used (JAVA) Create a program that calculates the minimum number of coins to give

Minimum Change Problem using Dynamic Programming and returning array of coins used (JAVA)

Create a program that calculates the minimum number of coins to give back as change and return the denomination of each coin to give back in an array using dynamic programming.

What to do:

Make a class to hold JUnit tests with at least four test cases for the method described below

o One test case should expect an Exception when an empty array of coins is sent in as a parameter

Make a class to hold a method that has two parameters: an array of coins for a coin system (for example 1, 5, 10, 25 for the smaller, commonly- used coins in US currency) and an amount for which to make change. The method should return a list of the coins that add up to the amount. For example, for the US coin system and an amount of 42, the method would return a list including 25, 10, 5, 1, 1.

o The method should throw an exception if the array of coins sent in as a parameter is empty.

o The method must use dynamic programming.

There should be no main method in your code. Execution should be triggered only by the JUnit test cases.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!