paint recipe converter I am building an application to store paint recipes.
In this a recipes are stored as follows:
product A : 1000 grams
product B : 5 grams
when the paint mixer go's to make the recipe he selects the amount of liters he wants.
Say for this example is is 1 liter.
the density of the products is as follows:
product A : 1000 gram/L
product B : 1772 gram/L
As a programmer this is not my specialty, can you help me make this formula?
I have the result from the original program but not the formula, according to that program the results should be: 

 product A : 997,186 grams, product B : 4,986 grams

PS. keep in mind in this example i use 2 products but in the program this can be more.
 A: By the first set of formulas you apparently mean that the ratio of $A$ to $B$ in the final product should be $200:1$ by weight. Then if $a$ is the number of grams of $A$, and $b$ the number of grams of $B$, we have $a = 200b$. The second set of formulas relates grams of each product to volume; since we want $1$ liter, we have
$$1 = \frac{a}{1000} + \frac{b}{1772}$$
since for example $\frac{a}{1000}$ gives the volume of one gram of $A$. Solving those two equations gives the values you provided (except for a factor of $1000$, which I suspect comes from a mistake in units between grams and kg somewhere).
Edit:
To generalize for more than two components, suppose there were a third component, $C$, and that for every $1000$ grams of $A$ we want $447$ grams of $C$. Suppose further that $C$ has a density of $600$ g/L. Then the equations become
\begin{align*}
   \frac{a}{b} &= \frac{1000}{5} = 200\quad\text{ (ratio of $A$ to $B$)} \\
   \frac{a}{c} &= \frac{1000}{447}\quad\text{ (ratio of $A$ to $C$)} \\
   1 &= \frac{a}{1000} + \frac{b}{1772} + \frac{c}{600}\quad\text{ (mixture required to get $1$ L)}
\end{align*}
Then $b = \frac{a}{200}$, $c = \frac{47}{1000}a$. Substituting into the third equation gives
$$1 = \frac{a}{1000} + \frac{b}{1772} + \frac{c}{600}
    = \frac{a}{1000} + \frac{a}{200\cdot 1772} + \frac{47a}{1000\cdot 600}.$$
Now solve for $a$.
In general, with $k$ components, there will be $k-1$ equations describing the ratios required depending on the number of grams of each in the recipe, and another single equation showing, for each component, the number of liters for a given number of grams and how to combine them to get a liter of product.
If I were trying to implement this in software, it's worth noting that the ratios are an attribute of the recipe (that is, they change when the recipe changes), while the densities are an attribute of the different paint components.
