Computer Science Canada

How to make a money change program?

Author:  Inuyasha22 [ Wed Apr 20, 2005 8:14 am ]
Post subject:  How to make a money change program?

hi everyone, i'm doing a money change program, like we can change USD into CND, or HKD into CND and so on, and i don't know what i should do in order to make them change money, so if there is anyone who can help me, that would be greatful, thank you~~~

Author:  Martin [ Wed Apr 20, 2005 8:25 am ]
Post subject: 

Well, the best way to do that would be to set a base currency. Let's say that we have 5 currencies: A, B, C, D, E.

Now, we'll assign A as the base currency: that is, all other currencies are going to be relative to A. We set the values of each currency in terms of 'how many A are they worth.'

A = 1
B = 0.4
C = 10
D = 24
E = 0.8

That is, one A is worth one A. One B is worth 0.4 A. One C is worth 10 A, and so on.

Now, let's say you want to know how many C's 5 D's are worth. What you do is convert D's into A's.

1 D is worth 24 A's, so therefor 5 D's are worth 24 * 5 = 120 A's
Now we convert from A's to C's.
1 C = 10 A
x C = 120 A

With some simple math, we determine that x = 12. Therefor, 5 D's are worth 12 C's.

Author:  Inuyasha22 [ Fri Apr 22, 2005 8:18 am ]
Post subject: 

the currency changes a lot, what if i want get a site that will help me change the currency i use everytime? how can i do that?


: