Classic Computer Magazine Archive ST-Log ISSUE 29 / MARCH 1989 / PAGE 14

APPLICATION

MEDIUM AND HIGH RESOLUTION

ChemCalc

BY RICHARD REPKA

While I was setting up my schedule this term at my college, I found that I needed an elective to fulfill my requirements. Being the type of person who likes to be challenged, I chose Chemistry 1, and I found that the class was not only challenging, but also very mundane, due to the repetition of calculating the molecular weight of various substances. As a programmer and owner of an ST, I saw the potential for a useful program to help me with chemistry.

ChemCalc is one of the most used programs I have ever written. Anyone taking chemistry—which happens to be a requirement for most majors—will find it very useful. It accepts whole formulas or only parts of a formula as input. The program will break the input down into separate elements, calculate the weight and find the elemental composition of the molecule.

Typing it in

Listing 1 is the ST BASIC program for ChemCalc. Type the program in, and then use ST Check found elsewhere in this issue to check your work.

Using the program

When entering a formula to be analyzed, you must use proper syntax. Each element symbol has one, two or three letters in it with the first letter always being a capital. For instance, sodium has "Na" as its symbol. Be sure to use Na and not NA. The program will tell you if it has found any error and ask you to please check your formula and re-enter it. There are also some special characters that the program will accept as input:

( — Start of a radical

) — End of a radical

* — Hydration

For example: Ba(NO3)2 * 5H2O

To use ChemCalc simply enter a formula and press Return. Some examples are:

H

N2

H2SO4

*7H2O

The program then checks your input, and if all is okay, it will tell you it is working. The longer the formula, the longer it will take. The program will then display the molecular weight in grams per mole (g/mol) and a table of elemental composition. The table will list up to eight different elements in your formula. For space reasons it cannot display more This should not be a problem as I have never encountered a formula with more than eight different elements. The program will then ask you if you want to enter another formula. A y or a Y will mean yes, and anything else will return you to ST BASIC.

Richard Repka is currently attending the University of South Florida where he is majoring in Information Systems Management. He expects to graduate "one of these days, if he's in the mood!" His other interests include playing Scrabble with his girlfriend.