Create a flowchart that inputs an amount and output the denomination breakdown by 100,50,20,10,5,1.
e.g. Amount: 237
Output: there are 2 100 peso
there are 0 50 peso
there are 1 20 peso
there are 1 10 peso
there are 1 5 peso
there are 2 2 peso


Hope you help me... coz i need it asap...
thanks... 2nd yr. IT

Dani AI

Generated

— the simplest, reliable approach is a greedy routine: always take as many of the largest denomination that fits, subtract their total, then move to the next smaller denomination. was pointing in this direction; his numeric example mixes a few intermediate values, but the method is sound. Below is a flowchart-friendly outline and a short C example you can test.

Start -> Input amount (integer, >= 0) -> Validate input (reject negatives/non-integers) -> Initialize denominations array = {100,50,20,10,5,1} and index = 0 -> Loop while index < length(denominations):

  • count = amount / denominations[index]
  • output count and denominations[index] (or skip zeros if you prefer)
  • amount = amount % denominations[index]
  • index = index + 1
    -> End

A compact C implementation (reads one integer, prints breakdown):

#include <stdio.h>

int main(void) {
    int amount;
    int denom[] = {100,50,20,10,5,1};
    int i;

    if (scanf("%d", &amount) != 1 || amount < 0) return 1;

    for (i = 0; i < 6; ++i) {
        int count = amount / denom[i];
        printf("there are %d %d peso\n", count, denom[i]);
        amount %= denom[i];
    }
    return 0;
}

Notes and gotchas: use integer arithmetic (or convert to the smallest currency unit if decimals matter). Skip printing zero counts if you want cleaner output. Greedy works for these standard denominations; for arbitrary coin sets greedy can fail — see the Change-making problem for counterexamples and dynamic programming alternatives.

Recommended Answers

All 3 Replies

Create a flowchart that inputs an amount and output the denomination breakdown by 100,50,20,10,5,1.
e.g. Amount: 237
Output: there are 2 100 peso
there are 0 50 peso
there are 1 20 peso
there are 1 10 peso
there are 1 5 peso
there are 2 2 peso


Hope you help me... coz i need it asap...
thanks... 2nd yr. IT

Do you really expect us to draw a flowchart for you? No we don't do that.
As for your question, write down the steps you would follow if your were doing in by hand on paper. Then you will have an idea of how to draw the flowchart.

even if there's no drawing of the flowchart that's fine with me... just tell me... please... need it badly...

How would you break down 231 in to 100,50,20,10,5,1.s?
These are the steps.

Divide 237 by 100 . The answer is 2. remainder is 31.
Divide the remainder ( 37 ) by 50. Answer is 0. remainder is 31.
Divide the remainder ( 37 ) by 20. Answer is 1. remainder is 17.
Divide the remainder ( 17 ) by 10. Answer is 1. remainder is 7.
Divide the remainder ( 7 ) by 5. Answer is 1. remainder is 2.
Divide the remainder ( 2 ) by 1. Answer is 2. remainder is 0.

So you draw the flowchart like this.
Step 1: Get next unprocessed element of the set { 100,50,20,10,5,1 }
Step 2: Divide the amount of money from that element.
Step 3: Store quotient ( Q ) and remainder ( R )
Step 4: You need a Q number of the current element
Step 5: If R is not 0, repeat from Step 1: Else Exit

Draw the flowchart for the above steps and you will get your answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.