// // Created by alex on 11/1/23. // #include "Element.h" double Element::getWeight(const string& name) { return weights.at(name); } string Element::find_empirical(map elms) { //Map will hold the elements with their values in moles map moles; map::iterator it; double lowest = 9999999; for(it = elms.begin(); it != elms.end(); it++) { double mole = it->second / getWeight(it->first); if(mole < lowest) lowest = mole; //cout << "Element " << it->first << " has this many moles: " << ceil(mole * 100) / 100 << endl; moles.insert(make_pair(it->first, mole)); } for(it = moles.begin(); it != moles.end(); it++) { it->second /= lowest; cout << "Element " << it->first << " has this many moles: " << ceil(it->second * 100) / 100 << endl; } return std::string(); } const map Element::weights = { {"H", 1.008}, {"He", 4.0026}, {"Li", 6.94}, {"Be", 9.0122}, {"B", 10.81}, {"C", 12.011}, {"N", 14.007}, {"O", 15.999}, {"F", 18.998}, {"Ne", 20.180}, {"Na", 22.990}, {"Mg", 24.305}, {"Al", 26.982}, {"Si", 28.085}, {"P", 30.974}, {"S", 32.06}, {"Cl", 35.45}, {"K", 39.098}, {"Ar", 39.948}, {"Ca", 40.08}, {"Sc", 44.956}, {"Ti", 47.867}, {"V", 50.942}, {"Cr", 51.996}, {"Mn", 54.94}, {"Fe", 55.85}, {"Ni", 58.693}, {"Co", 58.933}, {"Cu", 63.546}, {"Zn", 65.38}, {"Ga", 69.723}, {"Ge", 72.63}, {"As", 74.922}, {"Se", 78.96}, {"Br", 79.904}, {"Kr", 83.798}, {"Rb", 85.468}, {"Sr", 87.62}, {"Y", 88.906}, {"Zr", 91.224}, {"Nb", 92.906}, {"Mo", 95.95}, {"Tc", 98}, {"Ru", 101.07}, {"Rh", 102.91}, {"Pd", 106.42}, {"Ag", 107.87}, {"Cd", 112.41}, {"In", 114.82}, {"Sn", 118.71}, {"Sb", 121.76}, {"Te", 127.6}, {"I", 126.90}, {"Xe", 131.29}, {"Cs", 132.91}, {"Ba", 137.33}, {"La", 138.91}, {"Ce", 140.12}, {"Pr", 140.91}, {"Nd", 144.24}, {"Pm", 145}, {"Sm", 150.36}, {"Eu", 152.00}, {"Gd", 157.25}, {"Tb", 158.93}, {"Dy", 162.50}, {"Ho", 164.93}, {"Er", 167.26}, {"Tm", 168.93}, {"Yb", 173.04}, {"Lu", 175.00}, {"Hf", 178.49}, {"Ta", 180.95}, {"W", 183.84}, {"Re", 186.21}, {"Os", 190.23}, {"Ir", 192.22}, {"Pt", 195.08}, {"Au", 196.97}, {"Hg", 200.59}, {"Tl", 204.38}, {"Pb", 207.2}, {"Bi", 208.98}, {"Th", 232.04}, {"Pa", 231.04}, {"U", 238.03}, {"Np", 237}, {"Pu", 244}, {"Am", 243}, {"Cm", 247}, {"Bk", 247}, {"Cf", 251}, {"Es", 252}, {"Fm", 257}, {"Md", 258}, {"No", 259}, {"Lr", 262}, {"Rf", 267}, {"Db", 270}, {"Sg", 271}, {"Bh", 270}, {"Hs", 277}, {"Mt", 276}, {"Ds", 281}, {"Rg", 280}, {"Cn", 285}, {"Nh", 284}, {"Fl", 289}, {"Mc", 288}, {"Lv", 293}, {"Ts", 294}, {"Og", 294} };