Question

7. In the United States there are six coins in general circulation: 1, 5, 10, 25,...

7. In the United States there are six coins in general circulation: 1, 5, 10, 25, 50, 100 cent coins
It is possible to make change for 10 cents in the following ways: 1 dime, 2 nickels, 1 nickel 5 pennies, 10 pennies

Write a function, make_change that accepts an integer number of cents and calculates how many different ways one can make change for that amount using any number of coins, returning the integer count. What is the answer for 2 dollars?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//C++ program

#include<iostream>
using namespace std;

int count( int n )
{
int i, j, x, y;
int S[] = {1,5,10,25,50,100};
int m=sizeof(S)/sizeof (int);
int table[n+1][m];
  
for (i=0; i<m; i++)
table[0][i] = 1;
  
for (i = 1; i < n+1; i++)
{
for (j = 0; j < m; j++)
{
x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;

  
y = (j >= 1)? table[i][j-1]: 0;

table[i][j] = x + y;
}
}
  
return table[n][m-1];
}

int main()
{
cout<<"Total possible coin change for 2 dollar = "<<count(200);
return 0;
}

//sample output

Add a comment
Know the answer?
Add Answer to:
7. In the United States there are six coins in general circulation: 1, 5, 10, 25,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dolla...

    it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dollar amount as an integer: $5.34 is input as 534 b. Use a constant variable to represent each coin as a fixed value: const int NICKEL 5; c. Use division and the mod function to calculate the number of each coin. Change Calculator Enter dollar amount (as an integer): $534 The equivalent in coins: 21 Quarters 0 Dimes 1 Nickels...

  • Write a script called makeChange that prompts the user for a monetary amount in cents less...

    Write a script called makeChange that prompts the user for a monetary amount in cents less than or equal to 99 cents (i.e. less than a loonie) and then prints how change would be made for that amount out of quarters (25-cent coins), dimes (10-cent coins), nickels (5-cent coins) and pennies (1-cent coins). The change your script specifies should be the minimum number of coins. For example, when making change for 88 cents, the result should indicate 3 quarters, 1...

  • (In Python 3) Write a program with total change amount as an integer input, and output...

    (In Python 3) Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes So...

  • Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10...

    Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies. 2. Repeatedly prompt the user for a price in the form xX.xx, where X denotes a digit, or to enter q' to quit 3. When a price is entered a. If the price entered is negative, print an error message and start over requesting either a new price or to quit (indicated by entering a 'q)...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • implement a class called PiggyBank that will be used to represent a collection of coins. Functionality...

    implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...

  • In the U.S coin system, the penny is the basic coin, and it is equal to...

    In the U.S coin system, the penny is the basic coin, and it is equal to cent, a nickel is equivalent to 5 cents, a dime is equivalent to 10 cents, a quarter is equivalent to 25 cents, and half-dollar is equivalent to 50 cents. Design and implement a program that would make use of the functions shown below. Each function has a single int formal parameter Amount. a) HalfDollars (): Compute the maximum number of half-dollars that could be...

  • in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949)...

    in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949) - joshfor x M Inbox (4,224) - joshuar X ® AC ads/ACFrOgA6UB 1k4Z1i1xGLNQ1Lntj510 lutEUaA..pdf ECE 175: Computer Programming for Engineering Applications Lab Assignment #2 (Thursday sessions) Relevant Programming Concepts: • Branch Structure • Loop Problem 1 (15 points): Develop a C program that asks a user to enter a total change amount in cents) and outputs the change using the fewest coins. The coin...

  • PLease help!!! how to type them in Python !!!! Python help!! THank you so much Problem...

    PLease help!!! how to type them in Python !!!! Python help!! THank you so much Problem 1: (20 points) Optimal change You will write a program that uses the // and % operators to figure out how to give change for a specified amount using the minimum number of coins (quarters, dimes, nickels, cents). The good news is that our currency is specifically designed to make this problem easy. For a given number of cents, first use as many quarters...

  • C++ HW Question Your program will simulate a simple change maker for a vending machine. It...

    C++ HW Question Your program will simulate a simple change maker for a vending machine. It will start with a stock of coins and dollars. It will then repeatedly request the price for an item to be purchased or to quit. If given a price, it will accept nickels, dimes, quarters, one-dollar and five-dollar bills—deposited one at a time—in payment. When the user has deposited enough to cover the cost of the item, the program will calculate the coins to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT