A programs to compute the smallest number of coins needed to makeup a certain su
ID: 3617677 • Letter: A
Question
A programs to compute the smallest number of coins needed to makeup a certain sum. For example, if the coins available are 1, 5,10,25, and 100, then we need 5 coins to make 146 (100 + 25 + 10 +10 + 1).the programs should read in a list of up to 20 positive coins aswell as a target sum, and it will print the number of coins neededto make the target sum.
IN C++ please
it should run like this:
please enter Coins Available: User Input "1,5,10,25,100
Enter target Sum: user input 146
Needed coins: you'll need " blah+blah +blah" to make up your targetsum
: "100 + 25 + 10 + 10 + 1" to make up 146
Explanation / Answer
#include
// Three variables type (const int) for the coin values:
const
const
const
const
const
// This is a void that is named coin_amount and it points to one non specific value:
// I used it to point to the number of coins to be given out:
void
// This void is used for my spaces between my statements used in my program:
void
// This void is used to compute the number of coins that can be given to the user equvilent to the users pick:
void
// This void I used to say that the numbers choosen wasn't 1-99 coins:
void
int
{
{
cout <<
cout <<
spaces();
cout <<
cin >> mypick;
spaces();
{
cout << mypick <<
compute_coins(dollar, coin_amount, mypick);
cout <<
compute_coins(quarter, coin_amount, mypick);
cout <<
compute_coins(dime, coin_amount, mypick);
cout <<
compute_coins(nickel, coin_amount, mypick);
cout <<
compute_coins(penny, coin_amount, mypick);
cout <<
spaces();
}
{
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.