Header File

I'm making a periodic table program. It's for school next year, and it makes it faster to search and find the info on elements. Here's what I have so far.
It only goes up to Argon, atomic number 18 so far.

http://www.megaupload.com/?d=NEKXGKH9

I want to separate the elements up by various groups and put them i header files named:

ActElements.h
GasElements.h
LanthElements.h
LiquidElements.h
Metalloid.h
Metals.h
NonMetal.h
RepElements.h
SolidElements.h
TransitionElements.h


The reason I want to do this is so if you type in "gas", it pulls up all of the elements in GasElments.h then has a number beside each elment like:
1. Hydrogen
and when you press 1 it uses a goto command to pull up the information, but it would probably have to be in the function main.


Tell me if I need to be more clear, but this keeps it neater than having a lot of if statements like I do now.
is that some sort of virus or something?
No and why would you think that. It's a cyber periodic table.
closed account (zb0S216C)
wtf wrote:
is that some sort of virus or something?

o_0

Drue, can you be more clear and what you're asking, please? Your question is foggy at best.

Wazzak
when you press 1 it uses a goto command to pull up the information

You'd be better off using a function call instead.
This is a section from what I have now (only the first 2 elements to keep it short):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
void FuncElements()
{




    system("cls");
    system("title Periodic Table    ---Made by Drue Peters");

       MainScreen:
       WaitTime();
    ///////////////////////////////////////////////////////////
  
cout << "Type in the name of the element, the symbol, atomic mass or atomic number.\n"
         << "                 -";



        string Element;
        cin >> Element;
////////////////////////////////////////////////////////////////                             1
//////////////////  Hydrogen  //////////////////////////////////
//////////////////////////////////////////////////////////////////
     if (Element == "Hydrogen" || Element == "hydrogen" || Element == "1" ||
         Element == "h" || Element == "H" || Element == "1.008")
     {
           Hydrogen:
         system("cls");
         system("title Hydrogen");

         cout << "                 Hydrogen : Nonmetal     \n\n\n"
              << "Symbol                          : H\n"
              << "Atomic Number                   : 1\n"
              << "Neutrons                        : 0\n"
              << "Atomic Mass                     : 1.008\n"
              << "State of matter                 : Gas\n"
              << "Electrons in Outer Energy level : 1";

         system("pause>nul");
         goto MainScreen;
     }
////////////////////////////////////////////////////////////////////                        2
///////////////////// Helium ///////////////////////////////////////
////////////////////////////////////////////////////////////////////
    if (Element == "Helium" || Element == "helium" || Element == "2" ||
        Element == "HE" || Element == "he" || Element == "He" || Element == "hE" || Element == "4.003")
        {
            Helium:
            system("cls");
            system("title Helium");


         cout << "                 Helium : Nonmetal     \n\n\n"
              << "Symbol                          : He\n"
              << "Atomic Number                   : 2\n"
              << "Neutrons                        : 2\n"
              << "Atomic Mass                     : 4.003\n"
              << "State of matter                 : Gas\n"
              << "Electrons in Outer Energy level : 2\n"
              << "This is a noble gas.";




            system("pause>nul");
            goto MainScreen;
        }



As of now, I'm listing every element into the function
FuncElements()

, and you can only search by specifics. Name, symbol, atomic number, and atomic mass.
I want to set it up so you can type in "gas" (or generals) and it shows a list of all the gas elements
with a number in front of it like:
1. Hydrogen
2. Helium
and those two elements in the gas header will be listed, then when the user presses a 1
it uses a goto command to go to the hydrogen information. The reason I want it to be set up
this way is so I can have more than one list and keep the elements separated by the type.
Hydrogen can be in 3 lists: nonmetal, gas, and representative. It would keep it neater and I think easier, but it also gives me practice with including files.
I guess the main thing I was asking is if I can share information between all of those files and functions.. In line 27 and 48 I define Hydrogen and Helium, but I want to be able to link those to the other header files.

If the user types in "representative", I want to be able to show a list of all the representative elemetents that would be in the "RepElements.h" header. The same goes for all the other headers I listed above. Lanth standing for Lanthanide, and Act standing for Actinides.


Here's what I have for the GasElements so far. I dont' know if it's right so... help would be appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <windows.h>

using namespace std;

void GasElements()
{
    int GasEles;
    cout << "1. Hydrogen"
            "2. Helium";
            
            switch(GasEles)
            {
                case 1:
                goto Hydrogen;
                
                case 2:
                goto Helium;
                
            }
           
}


"Hydrogen" and Helium" would be located in the main source file.
Last edited on
@Moschops

How would I use a function call and make it go to the specific element?




EDIT: Oh. Sorry I get what you're saying, I think. Just make a function for each element, then call the function. Thanks.
Last edited on
Topic archived. No new replies allowed.