Question
Develop a program (JAVA) in a class named Coins that includes a method with the signature ways( int money) that uses recursion (possibly through recursive
Develop a program (JAVA) in a class named Coins that includes a method with the signature ways( int money) that uses recursion (possibly through recursive helper methods) to enumerate the distinct ways in which the given amount of money in cents can be changed into quarters, dimes, nickels, and pennies. Test your program from the main() method for various amounts of change by prompting the user to enter an amount in cents. For example, suppose the entered amount is 17. Then there are 6 ways to make change for this amount. Here is what exactly the I/O printout should look like:
Enter an amount in cents: 17
This amount can be changed in the following ways:
1) 1 dime, 1 nickel, 2 pennies
2) 1 dime, 7 pennies
3) 3 nickels, 2 pennies
4) 2 nickels, 7 pennies
5) 1 nickel, 12 pennies
6) 17 pennies
In your program you may use additional private helper methods, constructors, etc., as you deem necessary.
Restriction: Other than the I/O types, you may use only a constant amount of additional memory cells for your local variables and method parameters. So, you are not allowed to use elaborate structures such as arrays, lists, stacks or queues that may hold more than a constant number of elements.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started