Suppose a cashier owes a customer some change after a purchase was made. For instance, if an item cost 13 cents and the customer gave the cashier a one dollar bill, they would get back 87 cents in change.
In Greedy you will be writing a program that determines the fewest number of coins that can make up that change. Assuming only quarters, dimes, nickels and pennies are available, to give back 87 cents, you can give back 3 quarters, which leaves 87 – 75 or 12 cents, and then one dime and two pennies. So the smallest number of coins that can be returned is 3 + 1 + 2 or 6.
You may need to do something called “typecasting” to solve this problem. Typecasting is when we convert, for instance, a floating point number to an integer. Find out more in this video.
Get all the details about Problem 1-5: Greedy here.