Computer Science Canada Does not div/mod properly... |
Author: | Insectoid [ Thu Apr 17, 2008 8:21 am ] | ||
Post subject: | Does not div/mod properly... | ||
This is the 'vending machine' program that I am doing for my grade 10 computer engineering class. However, It says things like '5 quarters' and '7 loonies'. This isn't supposed to happen! Could you tell me what's wrong and why, so that I can fix it and know what I did wrong?
|
Author: | CodeMonkey2000 [ Thu Apr 17, 2008 3:18 pm ] | ||||
Post subject: | RE:Does not div/mod properly... | ||||
Processes? Why the heck are you using a process for the main program? It should be by itself. And as for you question,
|
Author: | Sean [ Thu Apr 17, 2008 3:26 pm ] |
Post subject: | Re: Does not div/mod properly... |
Also, CodeMonkey is right with what he says, however, Never fork, it's only necessary to do so when using Music. There is not need for the Main Program Process. |
Author: | CodeMonkey2000 [ Thu Apr 17, 2008 3:31 pm ] | ||
Post subject: | RE:Does not div/mod properly... | ||
Oh wait, the mod is right, but there is another problem.
Total should be change. ![]() |
Author: | Insectoid [ Fri Apr 18, 2008 8:04 am ] |
Post subject: | Re: Does not div/mod properly... |
Doh! It's stupid mistakes like these that really get me...to bad I can't just use the project I did for computer science (The classes overlap...a lot...). I got 113% on that one... My teacher sys I am supposed to use div/mod for this (I made a similar one using subtraction, but he rejected it ![]() The totaltwent := change div twent bit is supposed to calculate the number of that particular coin/bill denomination The following line, change := change mod twent calculates the remaining change. Thanks for helping! Now I have to see if that fixes it... |