0

Using the basic flowchart symbols, create a flowchart that calculates the Minimum Number of coins for making any amount of change less then a dollar. Prompt the user for an amount of change between 1 and 99 cents. Determine the minimum number of quarters, dimes, nickels and pennies that will add up to the amount of change requested. An example is shown below;

My question is that I need to find the minimum number of coins to make change, I need this in a flowchart format. I've sort of started but I'm having trouble with the counters and accumulators that are required for it. So far I have:

  1. Start
  2. Output: "Enter change amount (1-99)"
  3. Input x
  4. quarter=25, dime=10, nickel=5, penny=1

I know I need a counter and an accumulator but I'm not sure where it needs to go. I also know I need a formula to subtract the number of coins take out and it needs some repeating loops. All in all I need some help getting started and any descriptions of these would be greatly appreciated!

james13
  • 45
  • 1
  • 1
  • 7
  • Take a look at this answer: http://stackoverflow.com/questions/27936803/making-piggy-bank-program-in-java/27938123#27938123 It's exactly the same problem and I detailed every operation. – Vincent Durmont Jan 24 '15 at 06:03

1 Answers1

0

You need to use the %/modulus operator. It essentially gets the remainder of the number divided by the second number. It can be used like this:

int changeToGiveOut = 65;
int quarters = changeToGiveOut/25;
changeToGiveOut = changeToGiveOut%25; //What is left after taking out the quarters.
int dimes = changeToGiveOut/10;
changeToGiveOut = changeToGiveOut%10;

You can continue the rest in this pattern.

Bitcoin M
  • 1,206
  • 8
  • 24
  • That helps, a little... Maybe if I go into more detail about what my question is? Using the basic flowchart symbols, create a flowchart that calculates the Minimum Number of coins for making any amount of change less then a dollar. Prompt the user for an amount of change between 1 and 99 cents. Determine the minimum number of quarters, dimes, nickels and pennies that will add up to the amount of change requested. An example is shown below; – james13 Jan 24 '15 at 06:16
  • 2
    This is exactly what I gave you. You just need to continue the code with dimes and pennies. I'm not doing your homework for you. – Bitcoin M Jan 24 '15 at 07:11
  • Sorry.. I should have mentioned I can't use division... It's a practice in looping.... – james13 Jan 24 '15 at 07:18