E-Code

Molar mass from a chemical formula — a TI-89 Titanium program

By E-Code · updated

MOLAR89 is a TI-89 BASIC program for the TI-89 Titanium. Type a formula as text — C6H12O6, NaCl, Ca(OH)2 — and the program reads the element symbols, counts and one level of parentheses from the string and adds up the molar mass (28 common elements, IUPAC values).

What it asks for and what it shows

It asks for 1 value at its prompts. In the example below it shows MOLAR MASS.

Example run

One of its oracle test cases: “C6H12O6”. The inputs are typed in order, and the results are the values the case expects on the screen.

StepValue
You enter
Input 1C6H12O6
The screen shows
MOLAR MASS=180.156

How it's checked

7 test cases, each checked against an independent method. Replayed key by key on a virtual TI-89 Titanium, they make 21 checks.

How E-Code checks every program

Run it or put it on your calculator

Related programs

All TI-89 Titanium chemistry programs · All TI-89 Titanium programs