Skip to content

This repository contains two Java classes, CoinChange1.java and CoinChange2.java, which both use a greedy algorithm to convert a given amount (in cents) into change using the lowest combination possible.

License

Notifications You must be signed in to change notification settings

Adewale-1/CoinChange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Coin Change Calculator

This repository contains two Java classes, CoinChange1.java and CoinChange2.java, which both use a greedy algorithm to convert a given amount (in cents) into change using the lowest combination possible.

CoinChange1.java

CoinChange1.java uses a straightforward approach to calculate the change. It divides the given amount by the value of each denomination starting from the highest (dollar) to the lowest (penny), and calculates the remainder. This process is repeated for each denomination.

Usage

To use this class, simply run the main method. You will be prompted to enter an amount in cents. The program will then output the calculated change in dollars, half dollars, quarters, dimes, nickels, and pennies.

CoinChange2.java

CoinChange2.java uses a slightly different approach to calculate the change. It stores the denominations and their corresponding names in two separate arrays. It then uses a loop to calculate the change for each denomination.

Usage

To use this class, run the main method. You will be prompted to enter an amount in cents. The program will then output the calculated change in dollars, half dollars, quarters, dimes, nickels, and pennies.

Authors

These programs were written by A.Adenle.

License

This project is open source and available under the MIT License.

About

This repository contains two Java classes, CoinChange1.java and CoinChange2.java, which both use a greedy algorithm to convert a given amount (in cents) into change using the lowest combination possible.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages