Challenge: Make a Change Machine

Given infinite quarters, dimes, nickels, and pennies, calculate the minimum number of coins to represent a collection of amount ”C.” Propose a solution to test your skills in Java!

💰Change Machine?

A change machine is a kind of vending machine that accepts large amounts of currency and returns an equal amount of currency in smaller bills or coins.

Problem statement

You have to make such a change machine that only returns the change in the form of coinscoins.

You are supplied with an infinite number of quarters (25 cents)(25\ cents), dimes (10 cents)(10\ cents), nickels (5 cents)(5\ cents), and pennies (1 cent)(1\ cent). The user will enter any amount. For each amount, you have to return the minimum number of coins possible!

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.