For a Chemical Equation Balancer App (Android), how do I count the number of atoms of each element in each term?
- by Upas
This is my app:
If someone enters "C6H12O6+O2=CO2+H2O", then I have already written code to split the equation into terms, so in an ArrayList called rterms I have the strings:
C6H12O6
CO2
and in another ArrayList called pterms, I have:
CO2
H2O
I need to count the number of C's in each term of the reactants, so 6 for term 1, 0 for term 2, and then the H's and then O's. How would I do this? Any help is appreciated.