Question: Java - find minimum number of currency notes and coins for given amount Assume you are working on a Java application and you need to

Java - find minimum number of currency notes and coins for given amount

Assume you are working on a Java application and you need to build a feature to take in an input balance and convert it into denominations (bills/coins). You can assume this call will be made to 'your code' as a Java call, you do not need to worry about intake from HTTP/console/anything like that.

The intent is to convert the balance into the least number of bills/coins. The input balance is expressed in the lowest unit of currency (e.g. pennies for USD, cents for Euro.. etc).

Examples (USD):

Given the balance 87, the answer would be: 3 Quarters, 1 Dime, 2 Penny coins.

Given the balance 287, the answer would be: 2 Dollars, 3 Quarters, 1 Dime, 2 Penny coins.

Please make use of Object Oriented design in your implementation so that the code is easy to understand, maintain and enhancements to the feature can be accommodated in the future.

The KEY THING we are looking for is good OO design - appropriate objects, responsibilities, and relationships (following good Domain driven design) - do not sacrifice on that focus area, even if it means code doesn't compile/run

Example of a feature enhancement:

Add support for another currency (that uses different denominations):

e.g. for Euro (EURO): Given the balance 287, the answer would be: 1 2 coin, 1 50c, 1 20c, 1 10c, 1 5c, and 2 1c coins

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!