Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 (30 points): Enumeration of Coin Change Making Develop a program in a class named Coins that includes a method with the signature ways

image text in transcribed

Problem 1 (30 points): Enumeration of Coin Change Making Develop a program 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: This amount can be changed in the following ways: 1) 1 dime, 1 nickel, 2 penniles 2) 1 dime, 7 pennies 3) 3 nickels, 2 pennies 4) 2 nickels 7 pennies 5) Inick, 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 otypes, 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 Problem 1 (30 points): Enumeration of Coin Change Making Develop a program 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: This amount can be changed in the following ways: 1) 1 dime, 1 nickel, 2 penniles 2) 1 dime, 7 pennies 3) 3 nickels, 2 pennies 4) 2 nickels 7 pennies 5) Inick, 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 otypes, 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago