OK, so I am making this program for chem class so I can convert a molecule from grams to moles via my calculator. What the program does is prompt the user for the # of atoms in the molecule, then the amount in grams of the substance. Then for each pass of the loop the user must input the # of the element (i.e. Hydrogen = 1, Helium = 2, etc..). This has been working just swimmingly up until recently. I am seeing how it handles up to having the atomic weight of 19 atoms stored in it and it doesn't work too well. I input H2O into it, but the moles are all wrong. I put in 1 (hydrogen) which gives me the correct atomic weight, then 1 (again same result), then 8(oxygen) which gives me 8 as it's atomic weight instead of 16. Please help!
Here is the code thus far:
ClrHome 0->E 0->F 0->P Prompt D,C While E<D Prompt A Disp A If A=1 and P=0:1.01->A:1->P If A=2 and P=0:4.00->A:1->P If A=3 and P=0:6.94->A:1->P If A=4 and P=0:9.01->A:1->P If A=5 and P=0:10.81->A:1->P If A=6 and P=0:12.01->A:1->P If A=7 and P=0:14.01->A:1->P If A=8 and P=0:16.00->A::1->P If A=9 and P=0:19.00->A:1->P If A=10 and P=0:20.18->A:1->P If A=11 and P=0:22.99->A:1->P If A=12 and P=0:24.31->A:1->P If A=13 and P=0:26.98->A:1->P If A=14 and P=0:28.09->A:1->P If A=15 and P=0:30.97->A:1->P If A=16 and P=0:32.07->A:1->P If A=17 and P=0:35.45->A:1->P If A=18 and P=0:39.95->A:1->P If A=19 and P=0:39.10->A:1->P 0->P Disp A F+A->F 0->A E+1->E End C/F->C Disp C