Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Chemistry Dept. has asked you to develop a program that will calculate molecular weights of compounds given the chemical formula. For example, H2O (water)

The Chemistry Dept. has asked you to develop a program that will calculate molecular weights of compounds given the chemical formula. For example, H2O (water) would contain 2 hydrogen atoms weighting 1.008 and 1 oxygen weighting 15.999. The weight of water is 2 x 1.008 + 1 x 15.999 yielding 18.015 atomic weight.

For compounds, the format input to you program will be in the following form: element ( number of atoms) element (number of atoms) ... for example H2O would be represented H(2)O. If the ( )'s are not present, then assume one (1) atom. Another example acetic acid would be represented CH(3)COOH or C(2)H(4)O(2). Some elements have one letter symbol and some have two letter symbols.

If an element has two letters symbol representation ie Silver is Ag, the second letter will be lower case indicating it is part of the element representation. A list of all the chemical elements can be found in the data file 'Element.dat'. The elements are arranged one input element per line where the element name appears first followed by its atomic weight.

Ex. Al 26.98

Sb 121.75

S 32.06

Ba 137.34 ... A second input file 'Formula.dat' contains the test formulae/compounds to use in testing your program. There will be one formula per line. For the output, print out the formula you read in follow by its Molecular weight in a nice table form (ie line up the columns).

Output should look like this:

Formula Molecular Weight H(2)O 18.015 . .

Print out the link list of Elements and their weights and then print out each Formula and its Molecular Weight Restrictions: You are to use a link list data structure to hold the Symbols and their weights in sorted order. You are to use Functions/Procedures in your implementation. Format your output in a table form (ie headings and straight columns)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago