/ Published in: Java
Determine the minimum number of coins for change
Given any number between 1 and 99, determine how to give change with the minimum number of coins. You can assume that the coins are 1c, 2c, 5c, 10c, 20c and 50c.
Given any number between 1 and 99, determine how to give change with the minimum number of coins. You can assume that the coins are 1c, 2c, 5c, 10c, 20c and 50c.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ChangeCalculator { /** * @param args */ /*Scanner scn = new Scanner(System.in); Integer amount = scn.nextInt();*/ } List<Integer> changeList = new ArrayList<Integer>(); changeList.add(50); changeList.add(20); changeList.add(10); changeList.add(5); changeList.add(2); changeList.add(1); changeMap.put(change+"c", changeCount); remAmt = remAmt - (changeCount*change); } return changeMap; } //private static }
URL: http://java.dzone.com/articles/thursday-code-puzzler-change