How do i do this?
Author |
Message |
jhdho0204
|
Posted: Tue Sep 28, 2010 5:43 pm Post subject: How do i do this? |
|
|
How do i write a program that ask users for a amount then output the number of tonnies, loonies, quarters, dimes, nickels and pennies that form that amount
 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Srlancelot39

|
Posted: Tue Sep 28, 2010 6:19 pm Post subject: RE:How do i do this? |
|
|
do you need the program to output all possible combinations? or just the most logical eg. max out toonies, then max out loonies, then the next biggest etc? |
|
|
|
|
 |
DemonWasp
|
Posted: Tue Sep 28, 2010 6:27 pm Post subject: RE:How do i do this? |
|
|
Try working through an example on your own. Use paper and pencil, NOT computer or calculator. Think carefully about what you do at each step.
For example, take the amount $14.92. You know that you'd most likely receive this as: $10 + 2 toonies + 3 quarters + 1 dime + 1 nickel + 2 pennies.
Work through it like this:
A) $14.92 contains at most ONE $10 bill. Select the $10 bill; now you only need to deal with $4.92.
B) $4.92 contains at most TWO $2 coins. Select 2 $2 coins; now you only need to deal with $0.92.
C) $0.92 contains at most THREE quarters. Select ... deal with $0.17.
D) ... (fill in the blanks)
Next, form a set of steps to do that. Word them in English. Try your example again, following the steps exactly. Fix up your instructions where you've made mistakes.
Once you have a working instruction list, you can translate that into Turing (or whatever language). This last part is the easiest part. |
|
|
|
|
 |
Kloyd Niel
|
Posted: Tue Oct 12, 2010 1:30 am Post subject: Re: How do i do this? |
|
|
Hello Guys,
Thanks for the information that i read,
BTW im a newly one in this site but i learned lot of ideas about this site.
Thanks a lot for being part of this site. God Bless.
how to treat depression |
|
|
|
|
 |
DanShadow

|
|
|
|
 |
|
|