
Visual Logic
#1
Posted 04 May 2006 - 11:34 PM

#2
Posted 05 May 2006 - 01:02 AM

Cheers,
Tom
I am working on a program for my Logic and Design class and I am having serious issues. I have to design a program that will tell a cashier what specific change to give back, i.e. 96 cents = 3 quarters, 2 dimes and a penny. I can seem to get it to work and I dont know where I am going wrong. This is my first week of the course and I am already stuck, please help. I can also be reached on Yahoo or AIM as starrswrld.
#3
Posted 06 May 2006 - 07:46 PM

#4
Posted 06 May 2006 - 08:04 PM

I can give the same help and code that starrz and I worked out together. You must be pretty close to the answer if you are getting the correct number of quarters, but then we have to subtract that amount from our total cents.
First step is caclulate number of given coin in the total amount of cents. We can do this with integer division.
Input cents
# of quarters = cents \ 25 (This will return the number of times 25 is in cents)
Now, we need to code the modulos operation (what is the remainder of cents divided by 25). We already know the number of quarters from above. So, we need to subtract that number times 25 from cents.
Remaining cents = cents - ( (cents \ 25) * 25))
Now, we simply repeat this for the remaining coin denominations (10,5).
# of dimes = Remaining cents \ 10
Remaining cents = Remaining cents - ( (Remaing cents \ 10) * 10))
Hopefully that helps and I have attached a working *.vls example of the problem.
Cheers,
Tom
I'm in the same situation as you are Starrz. If anyone knows how to write the mathematical equation out to make the program run right, please help. I can get the quarters to come out right, but I can't get the dimes, nickels, and pennies to come out right. Any help will be greatly appreciated.
Attached Files
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users
As Featured On:






