$25.00 C++, Molecular Weight Program. Does Everything Asked. Compiled, Tested, Works. Lots Of Detailed Comments.
- This tutorial was purchased 1 time and hasn't been rated yet.
- Posted on Feb 24, 2009 at 08:19:55PM
A:
Preview: ... /* linear search goes through each and every element and checks to<br> see if we have the symbol that we are looking for, if we do then<br> we return its molecular weight. If we cannot find it then we<br> return 0.0. */<br>float linearSearch(Element table[117], int size, string symbol)<br>{<br> for (int i = 0; i < size; i++)<br> {<br> if (table[i].getSymbol() == symbol)<br> return table[i].getWeight();<br> }<br><br> return 0.0;<br>}<br><br><br>int main()<br>{<br> /* Declare an array of elements named table there are currentley<br> only 117 elements so we make it that size. We use the integer<br> elementCount to keep track of how many of those we are using<br> in this particular program with this particular file.<br> */<br><br> Element table[117];<br> int elementCount = 0;<br><br> //Open the file for reading<br> ifstream elementin("Element.txt", ios::in);<br><br> string symbol; // temporary variables to store the elements data<br> float weight;<br><br> //While there is still a symbol to read there will still be a weight to read<br> while ((elementin >> symbol) != NULL)<br> {<br> elementin >> weight;<br><br> //Set the elements properties<br> table[elementCou ...
The full tutorial is about 1791 words long plus attachments.
Attachments:
main.cpp (5K) (Preview)
preview.JPG (48K) (Preview)