[Solved]Java Please Problem Develop Recursive Method Determine Number Distinct Ways Given Amount M Q37101502
Java please
Problem:
Develop a recursive method to determine the number of distinct waysin which a given amount of money in cents can be changed intoquarters, dimes, nickels, and pennies. Each line of input containsan amount. For example, if the amount is 17 cents, then there aresix ways to make change:
1 dime, 1 nickel, and 2 pennies 1 dime, and 7 pennies 3 nickels and2 pennies 2 nickels and 7 pennies 1 nickel and 12 pennies 17pennies
The method specification is
public static int ways(int amount, int denomination)
For the value of denomination, 1 – penny, coins 2- nickel, 3 – dimeand 4 – quarter. The running result example is
Input the amount between 1 and 99: 17
There are 0 quarter, 1 dime, 1 nickel, 2 penny There are 0 quarter,1 dime, 0 nickel, 7 penny There are 0 quarter, 0 dime, 3 nickel, 2penny There are 0 quarter, 0 dime, 2 nickel, 7 penny There are 0quarter, 0 dime, 1 nickel, 12 penny There are 0 quarter, 0 dime, 0nickel, 17 penny
There are totally 6 ways.
Here are some input/output pairs. The first number in each pair isthe amount, and the second number is the number of ways in whichthe amount can be changed into quarters, dimes, nickels, andpennies:
17 6 5 2 10 4
COSC 3331 Data Structures and Algorithms Project3
25 13 42 31 61 73 99 213
Test your methods ways method with a main method that reads in aninteger amount in cents between 1 and 99, inclusive, and outputsthe total number of ways that amount can be changed into quarters,dimes, nickels, and pennies, and each way in detail.
Hint: Let us simplify the problem as follows:
Given a positive integer n, how many ways can we make change for ncents using pennies, nickels, dimes and quarters?
Recursively, we could break down the problem as follows:
To make change for n cents we could: 1) Give the customer aquarter. Then we have to make change for n-25 cents 2) Give thecustomer a dime. Then we have to make change for n-10 cents 3) Givethe customer a nickel. Then we have to make change for n-5 cents 4)Give the customer a penny. Then we have to make change for n-1cents.
Expert Answer
Answer to Java please Problem: Develop a recursive method to determine the number of distinct ways in which a given amount of mone… . . .
OR

