Advertisement
KeeganT

Compound Namer

Apr 3rd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. string elements[118];
  8. string elementsAbr[118];
  9. string ions[]{"Ammonium","Bicarbonate","Carbonate","Chlorate","Hydroxide","Nitrate","Nitrite","Permanganate","Phosphate","Phosphite","Sulfate","Sulfite"};
  10. string ionFormulas[]{"NH4","HCO3","CO3","ClO3","OH","NO3","NO2","MnO4","PO4","PO3","SO4","SO3"};
  11. int metalNums[]{1,2,3,10,11,12,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,53,54,55,56,
  12. 57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,
  13. 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117};
  14. int nonMetalNums[]{0,4,5,6,7,8,9,13,14,15,16,17,32,33,34,35,51,52,84,85};
  15. string metals[98];
  16. string nonMetals[20];
  17.  
  18. void getElements()
  19. {
  20.     ifstream file("elements.txt");
  21.     string text;
  22.     int index=0;
  23.     while(getline(file,text))
  24.     {
  25.         elements[index]+=text;
  26.         index++;
  27.     }
  28.     file.close();
  29. }
  30.  
  31. void getElementAbr()
  32. {
  33.     ifstream file2("elements_abr.txt");
  34.     string text2;
  35.     int index2=0;
  36.     while(getline(file2,text2))
  37.     {
  38.         elementsAbr[index2]+=text2;
  39.         index2++;
  40.     }
  41.     file2.close();
  42. }
  43.  
  44. void getMetals()
  45. {
  46.     for(int c=0;c<98;c++)metals[c]=elements[metalNums[c]];
  47. }
  48.  
  49. void getNonMetals()
  50. {
  51.     for(int c=0;c<20;c++)nonMetals[c]=elements[nonMetalNums[c]];
  52. }
  53.  
  54. void elementCount(int compound)
  55. {
  56.  
  57. }
  58.  
  59. int main()
  60. {
  61.     getElements();
  62.     getMetals();
  63.     getNonMetals();
  64.     string choice;
  65.     string lowAlphabet="abcdefghijklmnopqrstuvwxyz"
  66.     bool polyatomic=false;
  67.     cout<<"Type 'n' for Name or 'f' for Formula: ";
  68.     getline(cin,choice);
  69.     while(choice!="n"&&choice!="f")
  70.     {
  71.         cout<<"That is not a valid choice, please type 'n' for Name or 'f' for Formula: ";
  72.         cin>>choice;
  73.     }
  74.     if(choice=="n")
  75.     {
  76.         polyatomic=false;
  77.         string name;
  78.         cout<<"Enter the name of the compound: ";
  79.         getline(cin,name);
  80.         for(int c=0;c<12;c++)if(name.find(ions[c])!=string::npos)polyatomic=true;
  81.         if(polyatomic==true)
  82.         {
  83.  
  84.         }
  85.         else if(polyatomic==false)
  86.         {
  87.  
  88.         }
  89.     }
  90.     else if(choice=="f")
  91.     {
  92.         polyatomic=false;
  93.         int capitals=0;
  94.         string formula;
  95.         cout<<"Enter the formula of the compound: ";
  96.         cin>>formula;
  97.         for(int c=0;c<12;c++)if(formula.find(ionFormulas[c])!=string::npos)polyatomic=true;
  98.         if(polyatomic==true)
  99.         {
  100.             for(int c=0;c<12;c++)if(formula.find(ionFormulas[c])!=string::npos)string ion2=ions[c];
  101.             string firstElement2=formula.substr(0,1)
  102.             for(int c=0;c<12;c++)if(formula.find(elementsAbr[c])!=string::npos)cout<<elements[c];
  103.             cout<<ion<<endl;
  104.         }
  105.         else if(polyatomic==false)
  106.         {
  107.  
  108.         }
  109.     }
  110.  
  111. }
  112.  
  113. ///shit I don't think I can do this...
  114.  
  115. Hydrogen
  116. Helium
  117. Lithium
  118. Beryllium
  119. Boron
  120. Carbon
  121. Nitrogen
  122. Oxygen
  123. Fluorine
  124. Neon
  125. Sodium
  126. Magnesium
  127. Aluminum
  128. Silicon
  129. Phosphorus
  130. Sulfur
  131. Chlorine
  132. Argon
  133. Poatssium
  134. Calcium
  135. Scandium
  136. Titanium
  137. Vanadium
  138. Chromium
  139. Manganese
  140. Iron
  141. Cobalt
  142. Nickel
  143. Copper
  144. Zinc
  145. Gallium
  146. Germanium
  147. Arsenic
  148. Selenium
  149. Bromine
  150. Krypton
  151. Rubidium
  152. Strontium
  153. Yttrium
  154. Zirconium
  155. Niobium
  156. Molybedenum
  157. Technetium
  158. Ruthenium
  159. Rhodium
  160. Palladium
  161. Silver
  162. Cadmium
  163. Indium
  164. Tin
  165. Antimony
  166. Tellurium
  167. Iodine
  168. Xenon
  169. Cesium
  170. Barium
  171. Lanthanum
  172. Cerium
  173. Praseodymium
  174. Neodymium
  175. Promethium
  176. Samarium
  177. Europium
  178. Gadolinium
  179. Terbium
  180. Dysprosium
  181. Holmium
  182. Erbium
  183. Thulium
  184. Ytterbium
  185. Lutetium
  186. Hafnium
  187. Tantalum
  188. Tungesten
  189. Rhenium
  190. Osmium
  191. Iridium
  192. Platinum
  193. Gold
  194. Mercury
  195. Thallium
  196. Lead
  197. Bismuth
  198. Polinium
  199. Astatine
  200. Radon
  201. Francium
  202. Radium
  203. Actinium
  204. Thorium
  205. Protactinium
  206. Uranium
  207. Neptunium
  208. Plutonium
  209. Americium
  210. Curium
  211. Berkelium
  212. Californium
  213. Einsteinium
  214. Fermium
  215. Mendelevium
  216. Nobelium
  217. Lawrencium
  218. Rutherfordium
  219. Dubnium
  220. Seaborgium
  221. Bohrium
  222. Hassium
  223. Meitnerium
  224. Darmstadtium
  225. Roentgenium
  226. Copmicium
  227. Nihonium
  228. Flerovium
  229. Moscovium
  230. Livermorium
  231. Tennissine
  232. Oganesson
  233.  
  234. H
  235. He
  236. Li
  237. Be
  238. B
  239. C
  240. N
  241. O
  242. F
  243. Ne
  244. Na
  245. Mg
  246. Al
  247. Si
  248. P
  249. S
  250. Cl
  251. Ar
  252. K
  253. Ca
  254. Sc
  255. Ti
  256. V
  257. Cr
  258. Mn
  259. Fe
  260. Co
  261. Ni
  262. Cu
  263. Zn
  264. Ga
  265. Ge
  266. As
  267. Se
  268. Br
  269. Kr
  270. Rb
  271. Sr
  272. Y
  273. Zr
  274. Nb
  275. Mo
  276. Tc
  277. Ru
  278. Rh
  279. Pd
  280. Ag
  281. Cd
  282. In
  283. Sn
  284. Sb
  285. Te
  286. T
  287. Xe
  288. Cs
  289. Ba
  290. La
  291. Ce
  292. Pr
  293. Nd
  294. Pm
  295. Sm
  296. Eu
  297. Gd
  298. Tb
  299. Dy
  300. Ho
  301. Er
  302. Tm
  303. Yb
  304. Lu
  305. Hf
  306. Ta
  307. W
  308. Re
  309. Os
  310. Ir
  311. Pt
  312. Au
  313. Hg
  314. Tl
  315. Pb
  316. Bi
  317. Po
  318. At
  319. Rn
  320. Fr
  321. Ra
  322. Ac
  323. Th
  324. Pa
  325. U
  326. Np
  327. Pu
  328. Am
  329. Cm
  330. Bk
  331. Cf
  332. Es
  333. Fm
  334. Md
  335. No
  336. Lr
  337. Rf
  338. Db
  339. Sg
  340. Bh
  341. Hs
  342. Mt
  343. Ds
  344. Rg
  345. Cn
  346. Nh
  347. Fl
  348. Mc
  349. Lv
  350. Ts
  351. Og
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement