473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Change program-1

I forgot to mention in my other posting that the program is suppose to
figure out the minimum amount of different dollars and cents that
would be required for a given amount.
Jul 17 '05 #1
8 1869
> I forgot to mention in my other posting that the program is suppose to
figure out the minimum amount of different dollars and cents that
would be required for a given amount.


Why didn't m_nickles come out right using the pattern you used for the others?

LFS

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #2
On Mon, 17 Nov 2003 23:24:09 -0600, "Larry Serflaten"
<Fi******@RiskOfBeingSpam.med> wrote:
I forgot to mention in my other posting that the program is suppose to
figure out the minimum amount of different dollars and cents that
would be required for a given amount.


Why didn't m_nickles come out right using the pattern you used for the others?


Because he got it wrong for the rest ...

I would not mind running into such a system
.... reminds me of a faulty fruit machine I once ran into ...
Jul 17 '05 #3
"J French" <er*****@nowhere.com> wrote
On Mon, 17 Nov 2003 23:24:09 -0600, "Larry Serflaten"
<Fi******@RiskOfBeingSpam.med> wrote:
I forgot to mention in my other posting that the program is suppose to
figure out the minimum amount of different dollars and cents that
would be required for a given amount.


Why didn't m_nickles come out right using the pattern you used for the others?


Because he got it wrong for the rest ...


No, the others were not wrong.

I actually had a response typed up that would have done them in a loop, just
as you indicated, but I remembered that students usually have to learn the
hard way first, before finding the shortcuts and/or more efficient algorithms.
The more important question was the nickel problem as he indicated. Solving
that puzzle would let him continue on with the algorithm he chose, rather than
supply him with an idea that was not his own.

The question I posted was intended to get him to think about what the problem
was. Why didn't the nickles fit the pattern...

The problem was the quarters that were not fitting into the pattern he set up.
$1.00 for example, could be determined by getting the $5.00 modulus and
dividing that result by $1.00. That pattern works, it is not wrong for the task.

Quarters, likewise could be obtained by getting the .50 cent modulus and
dividing that result by .25 cents. From there on up, the values were nice
round modulii (?) of the values above it. For example, $10 Mod $5 would
be 0, and $20 Mod $10 would be 0. Likewise $5 Mod $1 would be 0 and
$1 Mod .50 cents would be 0, and so forth. They all would be 0, for all values
above itself. But 25 Mod 10 will not be 0. Those quarters screwed up the plan.

The answer is to pull out the quarters, then the dimes, to figure the number of
nickles.

m_nickles = ((m_amount Mod 25) Mod 10) \ 5

With that in place, the algorithm he chose will do the job. Even if I agree it
could be done using fewer variables, and fewer lines of code. I think the
solving of the nickles problem would be the better lesson at this time. Once he
recognizes there is a pattern, he will learn soon enough that patterns can be
applied using loops to reduce the required code.
LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #4
Top posted - for tersity

It was wrong - full stop

Think about 'residue'

If however you feel like giving me $50 change as:
2 * $20
+ 5 * $10
+ 20 * $5
.... etc

Then feel free, but be prepared to re-mortgage your home

The major problem with coding, is not coding
- it is learning how to think.

.... Abstraction ... Generalization .. Re-usability ..
Compartmentalization

And, given that it was obviously homework, if one bothers to help,
then one might as well give something that does not look too obviously
'acquired' from a NG

The real life answer would be :-

Dim oChange As New cChange ' Note we know life and death
oChange.Sum = N
S := oChange.ScreenText
oChange.PrintText X, Y ' send to printer

Of course cChange would Raise an Event to find the available
denominations, and ... perhaps the stock holding of those
denonimations.

On Tue, 18 Nov 2003 08:13:01 -0600, "Larry Serflaten"
<Fi******@RiskOfBeingSpam.med> wrote:
"J French" <er*****@nowhere.com> wrote
On Mon, 17 Nov 2003 23:24:09 -0600, "Larry Serflaten"
<Fi******@RiskOfBeingSpam.med> wrote:
>> I forgot to mention in my other posting that the program is suppose to
>> figure out the minimum amount of different dollars and cents that
>> would be required for a given amount.
>
>Why didn't m_nickles come out right using the pattern you used for the others?


Because he got it wrong for the rest ...


No, the others were not wrong.

I actually had a response typed up that would have done them in a loop, just
as you indicated, but I remembered that students usually have to learn the
hard way first, before finding the shortcuts and/or more efficient algorithms.
The more important question was the nickel problem as he indicated. Solving
that puzzle would let him continue on with the algorithm he chose, rather than
supply him with an idea that was not his own.

The question I posted was intended to get him to think about what the problem
was. Why didn't the nickles fit the pattern...

The problem was the quarters that were not fitting into the pattern he set up.
$1.00 for example, could be determined by getting the $5.00 modulus and
dividing that result by $1.00. That pattern works, it is not wrong for the task.

Quarters, likewise could be obtained by getting the .50 cent modulus and
dividing that result by .25 cents. From there on up, the values were nice
round modulii (?) of the values above it. For example, $10 Mod $5 would
be 0, and $20 Mod $10 would be 0. Likewise $5 Mod $1 would be 0 and
$1 Mod .50 cents would be 0, and so forth. They all would be 0, for all values
above itself. But 25 Mod 10 will not be 0. Those quarters screwed up the plan.

The answer is to pull out the quarters, then the dimes, to figure the number of
nickles.

m_nickles = ((m_amount Mod 25) Mod 10) \ 5

With that in place, the algorithm he chose will do the job. Even if I agree it
could be done using fewer variables, and fewer lines of code. I think the
solving of the nickles problem would be the better lesson at this time. Once he
recognizes there is a pattern, he will learn soon enough that patterns can be
applied using loops to reduce the required code.
LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


Jul 17 '05 #5
"J French" <er*****@nowhere.com> wrote

It was wrong - full stop
No, it was not wrong. The only problem it had was being a bit verbose.
He used more code than was necessary, but the method worked.

Think about 'residue'
Try it, before you summarily dismiss it.

If however you feel like giving me $50 change as:
2 * $20
+ 5 * $10
+ 20 * $5


Your calculations are off, he used the Mod operator:

(50 Mod 50) \ 20 = 0 * $20
(50 Mod 20) \ 10 = 0 * $10
(50 Mod 10) \ 5 = 0 * $5

The fact that it was a class project is precisely why I first wanted to
prompt him to think about the problem a little more. It is common
knowledge that to solve a problem, you first have to fully describe
the problem, to know what it is. In programming, describing the
problem often lends clues to the solution, which might be a good
lesson to learn, for those just getting into their studies.

LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #6
"Larry Serflaten" <Fi******@RiskOfBeingSpam.med> wrote in message news:<3f********@corp.newsgroups.com>...
"J French" <er*****@nowhere.com> wrote
On Mon, 17 Nov 2003 23:24:09 -0600, "Larry Serflaten"
<Fi******@RiskOfBeingSpam.med> wrote:
> I forgot to mention in my other posting that the program is suppose to
> figure out the minimum amount of different dollars and cents that
> would be required for a given amount.

Why didn't m_nickles come out right using the pattern you used for the others?


Because he got it wrong for the rest ...


No, the others were not wrong.

I actually had a response typed up that would have done them in a loop, just
as you indicated, but I remembered that students usually have to learn the
hard way first, before finding the shortcuts and/or more efficient algorithms.
The more important question was the nickel problem as he indicated. Solving
that puzzle would let him continue on with the algorithm he chose, rather than
supply him with an idea that was not his own.

The question I posted was intended to get him to think about what the problem
was. Why didn't the nickles fit the pattern...

The problem was the quarters that were not fitting into the pattern he set up.
$1.00 for example, could be determined by getting the $5.00 modulus and
dividing that result by $1.00. That pattern works, it is not wrong for the task.

Quarters, likewise could be obtained by getting the .50 cent modulus and
dividing that result by .25 cents. From there on up, the values were nice
round modulii (?) of the values above it. For example, $10 Mod $5 would
be 0, and $20 Mod $10 would be 0. Likewise $5 Mod $1 would be 0 and
$1 Mod .50 cents would be 0, and so forth. They all would be 0, for all values
above itself. But 25 Mod 10 will not be 0. Those quarters screwed up the plan.

The answer is to pull out the quarters, then the dimes, to figure the number of
nickles.

m_nickles = ((m_amount Mod 25) Mod 10) \ 5

With that in place, the algorithm he chose will do the job. Even if I agree it
could be done using fewer variables, and fewer lines of code. I think the
solving of the nickles problem would be the better lesson at this time. Once he
recognizes there is a pattern, he will learn soon enough that patterns can be
applied using loops to reduce the required code.
LFS


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


LFS

I know that there was a better way than the way that I was doing it,
but the requirements of the project forced me to do it the long way.
(Going through each variable vs doing a loop)

David
Jul 17 '05 #7
On Tue, 18 Nov 2003 11:39:01 -0600, "Larry Serflaten"
<Fi******@RiskOfBeingSpam.med> wrote:

<snip>

The fact that it was a class project is precisely why I first wanted to
prompt him to think about the problem a little more. It is common
knowledge that to solve a problem, you first have to fully describe
the problem, to know what it is. In programming, describing the
problem often lends clues to the solution, which might be a good
lesson to learn, for those just getting into their studies.


With the benefit of hindsight, I now follow what you said about
Nickles

In effect, you were saying that the rest of his code was wrong.

.... which is quite true ...
Jul 17 '05 #8
On 18 Nov 2003 12:30:44 -0800, ho*****@yahoo.com (David Horne) wrote:
<snip>

I know that there was a better way than the way that I was doing it,
but the requirements of the project forced me to do it the long way.
(Going through each variable vs doing a loop)

David


Look at it this way
- pretend you are writing real code - not air-ware

If the client is wrong you first gently explain that they are
arseholes
- if that does not work you verbally beat them up

In the real World - *you* are Quality Control

Anyway, you probably do not know this, but one common method of
teaching is to entice people down the wrong path
- and then show them the real way
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yongsing | last post by:
I have a Windows 2000 Server machine that runs DB2 UDB v7 fixpak 11. I also have a Java program that uses JDBC to insert data into the database. Sometimes, the program encounters SQL0302N error...
2
by: david | last post by:
When you right click on a file in windows, there is a property of type of file, which seems to associate this file with an application for it. For example, when you double click on a .doc file, the...
1
by: nicksop | last post by:
How can i change of a setup project in vb .net For example how can i change the path of C:\program files\myprogram\program.exe and make it D:\program files\myprogram\program.exe
3
by: Ubergeek | last post by:
I have a project (Win32 application) that I want to change to a console application. Does anyone know what to edit in which file, to implement the change?
3
by: vatsa | last post by:
Hi all, we can simply change value of PS1 from command prompt . but I want to change the value of PS1 from within a c program. i tried to do that using getenv & putenv. but it is n't...
8
by: bim_bom | last post by:
Hi, is there any tool to change naming convention in c++ sources? I mean something, that parses cpp and h files in my project, and it finds, what variables are there declared. I think, it should...
3
by: W C Hull | last post by:
We have a request from Auditing to modify the password an a local workstation administrative account every 90 days. We are developing two programs - a VB6 GUI program that will allow the...
1
by: monkey1001 | last post by:
my program is suppose to show my due change and i got it working but my change and coins are wrong how can i improve it thank you..(its supposed to be in java)
0
by: shellegreen | last post by:
Hello, I need help with some password changes that I have to do in some iPAQs. The company that I work has 3 models of iPAQ and 3 different versions of Windows Mobile (Microsoft Pocket PC...
3
by: Alan J. Salmoni | last post by:
Hello everyone, I searched through groups to find an appropriate answer to this one but could only find these which didn't meet my program's needs:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.