An Error with my change maker Program

Posted 04 October 2012 - 06:19 PM

Hey im new to this forum. Im in grade 10 taking programming for the first time and after 2 weeks of mindf***ing stuff I was given our first project making a change maker basically what its supposed to do is you place you amount of money ex.) 15.65 and its supposed to convert that amount to the least amount of change so it'll be like 7 toonies 1 loonie 2 quarters 1 dime and 1 nickel. After constatly bugging my teacher shes given me a hint were you can't divide decimals and x by 100 to remove any decimal after getting decently far I think? I was stumped when my program didnt want me to do what it wanted to do. I have basic knowlage that Mod means the remainder and \ is like interger division i think it means that it rounds what it divised or something and / is regular. I know you don't do homework but can you give me more hints or fix my error? Don't laugh please im a programming virgin

btw my error is that num3 too label1 displays how many toonies and num4 to label2 is supposed to display how many loonies but it doesnt and num5 to label3 is supposed to display how many quarters and so on thanks!

Re: An Error with my change maker Program

1. Use the INT function to round your number, so for your toonies (whatever they are), you would use INT(1565 / 200) which equals 7.

2. You then need to take into account what you've already used, so in this case, you used 7 toonies, or 1400 of your 1565 to pay out. So to calculate your next lower denomination, loonies (I feel like one using these terms), you would use a combination of the MOD function (this gives you the remainder) and the INT function to round again, so something like int((1565 mod 200)/100), which will give you 1 loonie.

See if you can use the above advice to complete your project.

Once you do, post back your code for others to see and reference in future.

Re: An Error with my change maker Program

Posted 06 October 2012 - 01:59 AM

Try reading my post again..... You missed out stage 1 and tried to use the Mod function straight off.

Also, to make your code easier to read, instead of using num1 to numX, try giving them meaningful names and using a naming convention. I thought that might be something they taught in the classes. Naming conventions usually combine a description of the datatype and a meaningful variable name.

So, for example:

' We use dbl to represent a Double, we would use int to represent and Integer and so on.
Dim dblToonies as double
dim dblLoonies as double
dim dblQuarters as double
etc.

This way it makes it easier for yourself and others to figure out what your trying to do. If I look at your code at the moment, I have no idea what num6 is and therefore, I have no idea what your calculation should be (slight exaggeration, but you get the picture).

So basically, think about the maths side of it. Write it down on a bit of paper if necessary (i.e.: A basic program design), then look at your code again, using the advice given.

Please don't think I'm being harsh with you, it's just easier to learn if you get there yourself with advice, than me just writing it for you.