Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <fstream>
- using namespace std;
- string elements[118];
- string elementsAbr[118];
- string ions[]{"Ammonium","Bicarbonate","Carbonate","Chlorate","Hydroxide","Nitrate","Nitrite","Permanganate","Phosphate","Phosphite","Sulfate","Sulfite"};
- string ionFormulas[]{"NH4","HCO3","CO3","ClO3","OH","NO3","NO2","MnO4","PO4","PO3","SO4","SO3"};
- 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,
- 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,
- 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117};
- int nonMetalNums[]{0,4,5,6,7,8,9,13,14,15,16,17,32,33,34,35,51,52,84,85};
- string metals[98];
- string nonMetals[20];
- void getElements()
- {
- ifstream file("elements.txt");
- string text;
- int index=0;
- while(getline(file,text))
- {
- elements[index]+=text;
- index++;
- }
- file.close();
- }
- void getElementAbr()
- {
- ifstream file2("elements_abr.txt");
- string text2;
- int index2=0;
- while(getline(file2,text2))
- {
- elementsAbr[index2]+=text2;
- index2++;
- }
- file2.close();
- }
- void getMetals()
- {
- for(int c=0;c<98;c++)metals[c]=elements[metalNums[c]];
- }
- void getNonMetals()
- {
- for(int c=0;c<20;c++)nonMetals[c]=elements[nonMetalNums[c]];
- }
- void elementCount(int compound)
- {
- }
- int main()
- {
- getElements();
- getMetals();
- getNonMetals();
- string choice;
- string lowAlphabet="abcdefghijklmnopqrstuvwxyz"
- bool polyatomic=false;
- cout<<"Type 'n' for Name or 'f' for Formula: ";
- getline(cin,choice);
- while(choice!="n"&&choice!="f")
- {
- cout<<"That is not a valid choice, please type 'n' for Name or 'f' for Formula: ";
- cin>>choice;
- }
- if(choice=="n")
- {
- polyatomic=false;
- string name;
- cout<<"Enter the name of the compound: ";
- getline(cin,name);
- for(int c=0;c<12;c++)if(name.find(ions[c])!=string::npos)polyatomic=true;
- if(polyatomic==true)
- {
- }
- else if(polyatomic==false)
- {
- }
- }
- else if(choice=="f")
- {
- polyatomic=false;
- int capitals=0;
- string formula;
- cout<<"Enter the formula of the compound: ";
- cin>>formula;
- for(int c=0;c<12;c++)if(formula.find(ionFormulas[c])!=string::npos)polyatomic=true;
- if(polyatomic==true)
- {
- for(int c=0;c<12;c++)if(formula.find(ionFormulas[c])!=string::npos)string ion2=ions[c];
- string firstElement2=formula.substr(0,1)
- for(int c=0;c<12;c++)if(formula.find(elementsAbr[c])!=string::npos)cout<<elements[c];
- cout<<ion<<endl;
- }
- else if(polyatomic==false)
- {
- }
- }
- }
- ///shit I don't think I can do this...
- Hydrogen
- Helium
- Lithium
- Beryllium
- Boron
- Carbon
- Nitrogen
- Oxygen
- Fluorine
- Neon
- Sodium
- Magnesium
- Aluminum
- Silicon
- Phosphorus
- Sulfur
- Chlorine
- Argon
- Poatssium
- Calcium
- Scandium
- Titanium
- Vanadium
- Chromium
- Manganese
- Iron
- Cobalt
- Nickel
- Copper
- Zinc
- Gallium
- Germanium
- Arsenic
- Selenium
- Bromine
- Krypton
- Rubidium
- Strontium
- Yttrium
- Zirconium
- Niobium
- Molybedenum
- Technetium
- Ruthenium
- Rhodium
- Palladium
- Silver
- Cadmium
- Indium
- Tin
- Antimony
- Tellurium
- Iodine
- Xenon
- Cesium
- Barium
- Lanthanum
- Cerium
- Praseodymium
- Neodymium
- Promethium
- Samarium
- Europium
- Gadolinium
- Terbium
- Dysprosium
- Holmium
- Erbium
- Thulium
- Ytterbium
- Lutetium
- Hafnium
- Tantalum
- Tungesten
- Rhenium
- Osmium
- Iridium
- Platinum
- Gold
- Mercury
- Thallium
- Lead
- Bismuth
- Polinium
- Astatine
- Radon
- Francium
- Radium
- Actinium
- Thorium
- Protactinium
- Uranium
- Neptunium
- Plutonium
- Americium
- Curium
- Berkelium
- Californium
- Einsteinium
- Fermium
- Mendelevium
- Nobelium
- Lawrencium
- Rutherfordium
- Dubnium
- Seaborgium
- Bohrium
- Hassium
- Meitnerium
- Darmstadtium
- Roentgenium
- Copmicium
- Nihonium
- Flerovium
- Moscovium
- Livermorium
- Tennissine
- Oganesson
- H
- He
- Li
- Be
- B
- C
- N
- O
- F
- Ne
- Na
- Mg
- Al
- Si
- P
- S
- Cl
- Ar
- K
- Ca
- Sc
- Ti
- V
- Cr
- Mn
- Fe
- Co
- Ni
- Cu
- Zn
- Ga
- Ge
- As
- Se
- Br
- Kr
- Rb
- Sr
- Y
- Zr
- Nb
- Mo
- Tc
- Ru
- Rh
- Pd
- Ag
- Cd
- In
- Sn
- Sb
- Te
- T
- Xe
- Cs
- Ba
- La
- Ce
- Pr
- Nd
- Pm
- Sm
- Eu
- Gd
- Tb
- Dy
- Ho
- Er
- Tm
- Yb
- Lu
- Hf
- Ta
- W
- Re
- Os
- Ir
- Pt
- Au
- Hg
- Tl
- Pb
- Bi
- Po
- At
- Rn
- Fr
- Ra
- Ac
- Th
- Pa
- U
- Np
- Pu
- Am
- Cm
- Bk
- Cf
- Es
- Fm
- Md
- No
- Lr
- Rf
- Db
- Sg
- Bh
- Hs
- Mt
- Ds
- Rg
- Cn
- Nh
- Fl
- Mc
- Lv
- Ts
- Og
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement