Hey everyone,
I'm having an issue. I believe that all, or at least most of you, know what a cross method equation is. If not, here's an example:
36 g of water - 46 g of sodium
x g of water - 1 g of sodium
x = 36 * 1 / 46 = about 0,78 g```
Coding this in C# is *especially* challenging. And no, I didn't choose chemical application of this method as an example without a reason, as I'm working on a chemical reaction simulator in unity. Moving on, one of the things you have to do is to compare which of the *two* (or more) x, y, z etc. (the output) is the greatest, aka, x > y > z and so on, and only conduct further calculations on that one specific result. It's very challenging because the data is stored in arrays, with the database looking like this:
```json
{
"Na + H2O": {
"Output": ["NaOH", "H2"],
"Balanced": "2Na + 2H2O → 2NaOH + H2",
"Exothermic": true,
"State": [ "liquid", "gas" ],
"MeltingPoint": 318,
"BoilingPoint": 1388,
"Solubility": 109,
"SpecificHeat": 3.24,
"AtomicMass": [ 46, 36 ],
"MolecularMass": [ 80, 2 ],
"Stechiometry": [36, 46]
}
}```
For the sake of simplicity, we will focus on the values that really matter: "AtomicMass", "MolecularMass", "Stechiometry" (And yes, I know that they all are essentially all and the same, perhaps after I got an answer I will manage to make to fit this all into a single value).
In order to calculate the `x`, I'm using the following code:
```cs
Check = compoundInfo[equationFormat].Stechiometry[i] * ReactantAmount[fetchNameReactant] / compoundInfo[equationFormat].AtomicMass[i];```
As I said, the difficulty here is that you've gotta calculate all of the values and then compare them. And note that there *probably* won't be a constant amount of elements in an array depending on a kind of compound, so yeah. Any help would be appreciated.