What does a progam on how to make change for 25 cents look like?

Recommended Answers

All 3 Replies

The same way they taught you in 1st grade!

If usually starts with headers, then int main() . Then there's an input of some kind.
Then you get some if statements with some math intermixed, maybe even a loop or three, and finally some output statements.

I just asked my second grader (going to be in 3rd in Fall) how they would make change!


So you just bought something for 59 cents and handed the cashier a dollar, so 41 cents change.

41 cents
-25 quarter
16 (no more quarter, next size dime
-10 dime
6 (dime too big, try nickel)
-5 nickel
1 (nickel too big, try penny)
-1 penny
0 done!

Let's say no quarters in the drawer
41 cents
- 10 dime
31
-10 dime
21
-10 dime
11
-10 dime
1
nickel too big
-1 penny
0
done

*** So do it exactly that same way in code ***

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.