Periodic Table

I wrote a "Periodic Table" program, and would like..
1) Any ideas to make better
2) Any corrections to wrong data info
3) Instructive criticism.

Here's the 'Element_Data.txt'
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
118
1 13 5 H Hydrogen 1.0079  -259 -253 0.09 1776 13.5984 7 0
2 64 5 He Helium 4.0026 -272 -269 0.18 1895 24.5874 9 0
3 13 7 Li Lithium 6.941 180 1347 0.53 1817 5.3917 0 2
4 16 7 Be Beryllium 9.0122 1278 2970 1.85 1797 9.3227 1 2
5 49 7 B Boron 10.811 2300 2550 2.34 1808 8.298 10 2
6 52 7 C Carbon 12.0107 3500 4827 2.26 0 11.2603 7 2
7 55 7 N Nitrogen 14.0067 -210 -196 1.25 1772 14.5341 7 0
8 58 7 O Oxygen 15.9994 -218 -183 1.43 1774 13.6181 7 0
9 61 7 F Fluorine 18.9984 -220 -188 1.7 1886 17.4228 8 0
10 64 7 Ne Neon 20.1797 -249 -246 .9 1898 21.5645 9 0
11 13 9  Na Sodium 22.9897 98 883 .97 1807 5.1391 0 2
12 16 9 Mg Magnesium 24.305 639 1090 1.74 1755 7.6462 1 2
13 49 9 Al Aluminium 26.9815 660 2467 2.7 1825 5.9858 5 2
14 52 9 Si Silicon 28.0855 1410 2355 2.33 1824 8.1517 10 2
15 55 9 P Phosphorus 30.9738 44 280 1.82 1669 10.4867 7 2
16 58 9 S Sulphur 32.065 113 445 2.07 0 10.36 7 2
17 61 9 Cl Chlorine 35.453 -10 -35 3.32 1774 12.9676 8 0
18 64 9 Ar Argon 39.948 -189 -186 1.78 1894 15.7596 9 0
19 13 11 K Potassium 39.0983 64 774 .86 1807 4.3407 0 2
20 16 11 Ca Calcium 40.078 839 1484 1.55 1808 6.1132 1 2
21 19 11 Sc Scandium 44.9559 1539 2832 2.99 1879 6.5615 4 2
22 22 11 Ti Titanium 47.867 1660 3287 4.54 1791 6.8281 4 2
23 25 11 V Vanadium 50.9415 1890 3380 6.11 1830 6.7462 4 2
24 28 11 Cr Chromium 51.9961 1857 2672 7.19 1797 6.7665 4 2
25 31 11 Mn Manganese 54.938 1245 1962 7.43 1774 7.434 4 2
26 34 11 Fe Iron 55.845 1535 2750 7.87 0 7.9024 4 2
27 37 11 Co Cobalt 58.9332 1495 2870 8.9 1735 7.881 4 2
28 40 11 Ni Nickel 58.6934 1453 2732 8.9 1751 7.6398 4 2
29 43 11 Cu Copper 63.546 1083 2567 8.96 0 7.7264 4 2
30 46 11 Zn Zinc 65.39 420 907 7.13 0 9.3942 4 2
31 49 11 Ga Gallium 69.723 30 2403 5.91 1875 5.9993 5 2
32 52 11 Ge Germanium 72.64 937 2830 5.32 1886 7.8994 10 2
33 55 11 As Arsenic 74.9216 81 613 5.72 0 9.7886 10 2
34 58 11 Se Selenium 78.96  217 685 4.79 1817 9.7524 7 2
35 61 11 Br Bromine 79.904 -7 59 3.12 1826 11.8138 8 1
36 64 11 Kr Krypton 83.8 -157 -153 3.75 1898 13.9996 9 0
37 13 13 Rb Rubidium 85.4678 39 688 1.63 1861 4.1771 0 2
38 16 13 Sr Strontium 87.62 769 1384 2.54 1790 5.6949 1 2
39 19 13 Y Yttrium 88.9059 1523 3337 4.47 1794 6.2173 4 2
40 22 13 Zr Zirconium 91.224 1852 4377 6.51 1789 6.6339 4 2
41 25 13 Nb Niobium 92.9064 2468 4927 8.57 1801 6.7589 4 2
42 28 13 Mo Molybdenum 95.94 2617 4612 10.22 1781 7.0924 4 2
43 31 13 Tc Technetium 98 2200 4877 11.5 1937 7.28 4 3
44 34 13 Ru Ruthenium 101.07 2250 3900 12.37 1844 7.3605 4 2
45 37 13 Rh Rhodium 102.9055 1966 3727 12.41 1803 7.4589 4 2
46 40 13 Pd Palladium 106.42 1552 2927 12.02 1803 8.3369 4 2
47 43 13 Ag Silver 107.8682 962 2212 10.5 0 7.5762 4 2
48 46 13 Cd Cadmium 112.411 321 765 8.65 1817 8.9938 4 2
49 49 13 In Indium 114.818 157 2000 7.31 1863 5.7864 5 2
50 52 13 Sn Tin 118.71 232 2270 7.31 0 7.3439 5 2
51 55 13 Sb Antimony 121.76 630 1750 6.68 0 8.6084 10 2 
52 58 13 Te Tellurium 127.6 449 990 6.24 1783 9.0096 10 2
53 61 13 I Iodine 126.9045 114 184 4.93 1811 10.4513 8 2
54 64 13 Xe Xenon 131.293 -112 -108 5.9 1898 12.1298 9 0
55 13 15 Cs Cesium 132.9055 29 678 1.87 1860 3.8939 0 1
56 16 15 Ba Barium 137.327 725 1140 3.59 1808 5.2117 1 2
57 19 15 La Lanthanum 138.9055 920 3469 6.15 1839 5.5769 4 2
58 25 21 Ce Cerium 140.116 795 3257 6.77 1803 5.5387 2 2
59 28 21 Pr Praseodymium 140.9077 935 3127 6.77 1885 5.473 2 2
60 31 21 Nd Neodymium 144.24 1010 3127 7.01 1885 5.525 2 2
61 34 21 Pm Promethium 145 1100 3000 7.3 1945 5.582 2 3
62 37 21 Sm Samarium 150.36 1072 1900 7.52 1879 5.637 2 2
63 40 21 Eu Europium 151.964 822 1597 5.24 1901 5.6704 2 2
64 43 21 Gd Gadolinium 157.25 1311 3233 7.9 1880 6.1501 2 2
65 46 21 Tb Terbium 158.9253 1360 3041 8.23 1843 5.8638 2 2
66 49 21 Dy Dysprosium 162.5 1412 2562 8.55 1886 5.9389 2 2
67 52 21 Ho Holmium 164.9303 1470 2720 8.8 1867 6.0215 2 2
68 55 21 Er Erbium 167.259 1522 2510 9.07 1842 6.1077 2 2
69 58 21 Tm Thulium 168.9342 1545 1727 9.32 1879 6.1843 2 2
70 61 21 Yb Ytterbium 173.04 824 1466 6.9 1878 6.2542 2 2
71 64 21 Lu Lutetium 174.967 1656 3315 9.84 1907 5.4259 2 2
72 22 15 Hf Hafnium 178.49 2150 5400 13.31 1923 6.8251 4 2
73 25 15 Ta Tantalum 180.9479 2996 5425 16.65  1802 7.5496 4 2
74 28 15 W Tungsten 183.84 3410 5660 19.35 1783 7.864 4 2
75 31 15 Re Rhenium 186.207 3180 5627 21.04 1925 7.8335 4 2
76 34 15 Os Osmium 190.23 3045 5027 22.6 1803 8.4382 4 2
77 37 15 Ir Iridium 192.217 2410 4527 22.4 1803 8.967 4 2
78 40 15 Pt Platinum 195.078 1772 3827 21.45 1735 8.9587 4 2
79 43 15 Au Gold 196.9665 1064 2807 19.32 0 9.2255 4 2
80 46 15 Hg Mercury 200.59 -39 357 13.55 0 10.4375 4 1
81 49 15 Tl Thallium  204.3833 303 1457 11.85 1861 6.1082 5 2
82 52 15 Pb Lead 207.2 327 1740 11.35 0 7.4167 5 2
83 55 15 Bi Bismuth 208.9804 271 1560 9.75 0 7.2856 5 2
84 58 15 Po Polonium 209 254 962 9.3 1898 8.417 10 2
85 61 15 At Astatine 210 302 337 0 1940 9.3 8 2
86 64 15 Rn Radon 222 -71 -62 9.73 1900 10.7485 9 0
87 13 17 Fr Francium 223 27 677 0 1939 4.0727 0 1
88 16 17 Ra Radium 226 700 1737 5.5 1898 5.2784 1 2
89 19 17 Ac Actinium 227 1050 3200 10.07 1899 5.17 4 2
90 25 23 Th Thorium 232.0381 1750 4790 11.72 1829 6.3067 3 2
91 28 23 Pa Protactinium 231.0359 1564 0 15.4 1913 5.89 3 2
92 31 23 U Uranium 238.0289 1132 3818 18.95 1789 6.1941 3 2
93 34 23 Np Neptunium 237 640 3902 20.2 1940 6.2657 3 3
94 37 23 Pu Plutonium 244 640 3235 19.84 1940 6.0262 3 3
95 40 23 Am Americium 243 994 2607 13.67 1944 5.9738 3 3
96 43 23 Cm Curium 247 1340 0 13.5 1944 5.9915 3 3
97 46 23 Bk Berkelium 247 986 0 14.78 1949 6.1979 3 3
98 49 23 Cf Californium 251 900 0 15.1 1950 6.2817 3 3
99 52 23 Es Einsteinium 252 860 0 0 1952 6.42 3 3
100 55 23 Fm Fermium 257 1527 0 0 1952 6.5 3 3
101 58 23 Md Mendelevium 258 0 0 0 1955 6.58 3 3
102 61 23 No Nobelium 259 1827 0 0 1958 6.65 3 3
103 64 23 Lr Lawrencium 262 1627 0 0 1961 4.9 3 3
104 22 17 Rf Rutherfordium 261 0 0 0 1964 0 4 3
105 25 17 Db Dubnium 262 0 0 0 1967 0 4 3
106 28 17 Sg Seaborgium 263 0 0 0 1974 0 4 3
107 31 17 Bh Bohrium 262 0 0 0 1981 0 4 3
108 34 17 Hs Hassium 265 0 0 0 1984 0 4 3
109 37 17 Mt Meitnerium 266 0 0 0 1982 0 4 3
110 40 17 Ds Darmstadtium 281 0 0 0 1994 0 4 3
111 43 17 Rg Roentgenium 272 0 0 0 1994 0 4 3
112 46 17 Cn Copernicium 285 0 0 0 1996 0 4 3
113 49 17 ut Ununtrium 284 0 0 0 2003 0 5 3
114 52 17 Fl Flerovium 289 0 0 0 1999 0 5 3
115 55 17 up Ununpentium 288 0 0 0 2003 0 5 3
116 58 17 Lv Livermorium 292 0 0 0 2000 0 5 3
117 61 17 us Ununseptium 0 0 0 0 2010 0 8 3
118 64 17 uo Ununoctium 294 0 0 0 2002 0 9 3
Here is the part one of the program
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
// Periodic Table.cpp : main project file.

#include <iostream>
#include <conio.h>
#include <fstream>
#include <iomanip>
#include <vector>
#include <string>
#include <windows.h>


using namespace std;
using namespace System;

struct Element
{
	int Atomic_Number;
	int x;
	int y;
	string Symbol;
	string Name;
	double Atomic_Weight;
	float Melting_Point;
	float Boiling_Point;
	double Density;
	int Discovery_Year;
	double Ionization_Energy;
	int Element_Type;
	int Element_State;
};

void display(vector< Element >&, int, int );
void element(int,int);
void Show_Element(vector< Element >&, int, int, int );
void welcome_screen();
void Fill_Vector(vector< Element >&, ifstream& ElementStream);
void Box(int, int, int, int, int, int, int, int, int, int);
void text(int,int);
void gotoXY(int,int);
void gotoXY(int,int,string);
void frame();
void clrscr();
void setcursor(bool visible, DWORD size);
void WaitKey();

#define ENTER 13
#define ESC 27
#define UP 72
#define LEFT 75
#define RIGHT 77
#define DOWN 80

#define on ,

enum Colors{
  black,          //  0
  dark_blue,      //  1
  dark_green,     //  2
  dark_cyan,      //  3
  dark_red,       //  4
  dark_magenta,   //  5
  dark_yellow,    //  6
  light_gray,     //  7
  dark_gray,      //  8
  light_blue,     //  9
  light_green,    // 10
  light_cyan,     // 11
  light_red,      // 12
  light_magenta,  // 13
  light_yellow,   // 14
  white           // 15
  };


const int width = 80, height = 30;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void main()
{
	string rub(58,' ');
	string shadowline(39,'\xC4');
	Console::SetWindowSize(width, height );
	vector <Element> Number;
	ifstream ElementStream;
	ElementStream.open("Element_Data.txt");

	Fill_Vector( Number, ElementStream);
	Box(0,0,0,78,25,black on light_gray,0,0,0);
	setcursor(0,0);
	welcome_screen();
	Sleep(1500);
	Box(2,25,9,28,9,black on light_gray,0,0,0);
	gotoXY(36,10,"WELCOME");
	gotoXY(36,13,"TO  THE");
	gotoXY(33,16,"PERIODIC TABLE");

	Sleep(3000);

	display(Number, 13,5);
 Box(2,20,12,39,8,black on light_yellow,0,0,0);
 text(black on dark_cyan);
 gotoXY(59,13,"e");
 gotoXY(59,14,"\xC4");
 gotoXY(59,15,"o");
 gotoXY(59,16,"\xC4");
 gotoXY(59,17,"v");
 gotoXY(59,18,"\xC4");
 gotoXY(59,19," ");
 gotoXY(21,20,shadowline);
 for(int x=0;x<12;x++)
	 gotoXY(24+x*3,20,"\xC2");
 Console::SetWindowSize(width, height );
 text(black on light_yellow);
 gotoXY(27,13, "Program Written Using :");
 gotoXY(23,14,"Microsoft Visual C++ 2012 Express");
 gotoXY(28,16,"Written By: whitenite1");
 gotoXY(26,18,"Written In : December 2012");
 text(black on light_gray);
 gotoXY(12,28, rub);
 gotoXY(22,28);
 WaitKey();
}

void display(vector< Element >& Number, int x, int y)
{
	string Element_Group[11] = { "Alkali Metal","Alkaline Earth Metal","Lanthanide","Actinide","Transition Metal","Basic Metal","Semi-Metal","Nonmetal","Halogen","Noble Gas","Metalloid"};
	string State[4] = {"At Room Temp: Gas","At Room Temp: Liquid","At Room Temp: Solid","Artifically Prepared" };
	text(black on light_gray);
	
	int i,j, g, Num;
	
	Box(2,8,1,63,26,black on light_cyan,2,dark_gray on light_gray);
	
	gotoXY(30,0,"\xDA\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xBF");
	gotoXY(30,1,"\xB5 PERIODIC TABLE \xC6");
	gotoXY(30,2,"\xC0\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xD9");
	gotoXY(12,4);
	cout<<'\xDA';
	for (i=13;i<64;i+=3)
	{
		gotoXY(i,4);
		cout << "\xC4\xC4\xC2";
	}
	cout << "\xC4\xC4\xBF";
	for(j=5;j<23;j+=2)
	{
		gotoXY(12,j);
		cout << "\xB3   ";
		gotoXY(12,j+1);
		cout << "\xc3\xc4\xC4";

		for (i=15;i<64;i+=3)
		{
			gotoXY(i,j);
			cout << "\xB3  ";
			gotoXY(i,j+1);
			cout << "\xC5\xc4\xC4";
		}
		gotoXY(66,j , "\xB3");
		gotoXY(66,j+1,"\xB4");
	}

	gotoXY(12,23);
	cout << '\xB3';
	gotoXY(12,24);
	cout << '\xC0';

	for (i=13;i<65;i+=3)
	{
		gotoXY(i,23);
		cout << "  \xB3";
		gotoXY(i,24);
		cout << "\xC4\xC4\xC1";
	}
	gotoXY(66,24);
	cout << '\xD9';

	gotoXY(12,18);
	cout << '\xC0';
	gotoXY(12,19);
	cout << " ";
	gotoXY(12,20);
	cout << '\xDA';

	for (i=13;i<65;i+=3)
	{
		gotoXY(i,18);
		cout << "\xC4\xC4\xC1";
		gotoXY(i,19);
		cout << "   ";
		gotoXY(i,20);
		cout << "\xC4\xC4\xC2";
	}
	gotoXY(66,18);
	cout << '\xD9';
	gotoXY(66,19);
	cout << " ";
	gotoXY(66,20);
	cout << '\xBF';

	gotoXY(15,4,"\xBF  ");
	gotoXY(18,8,"\xB4  ");
	
	for (i=16;i<63;i++)
	{
		gotoXY(i,4," ");
		gotoXY(i,5," ");
		if(i>48 && i%3==0)
			gotoXY(i,6,"\xC2");
	}
	gotoXY(63,4,"\xDA");

	gotoXY(18,6,"\xBF  ");
	for (i=21;i<48;i++)
	{
		gotoXY(i,6," ");
		gotoXY(i,7," ");
		gotoXY(i,8," ");
		gotoXY(i,9," ");
		
	}
	
	gotoXY(48,6,"\xDA");
	gotoXY(48,8,"\xC3");
	
	for (i=19;i<48;i++)
	{
		gotoXY(i,7," ");
		gotoXY(i,9," ");
	}

	for(i=21;i<46;i+=3)
		gotoXY(i,10,"\xC2");

	gotoXY(12,20);
	cout << "\xDA\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4";
	gotoXY(15,22);
	cout << "\xC4\xC4\xC4\xC4\xC4\xC4\xC4";
	gotoXY(12,24);
	cout << "\xC0\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4";
	gotoXY(13,21);
	cout<<"Lanthanides";
	gotoXY(14,23);
	cout<<"Actinides";

	for(i=0;i<118;i++)
		gotoXY(Number[i].x, Number[i].y, Number[i].Symbol);

	Console::SetWindowSize(width, height );
	
	i=x,j=y;
	
	do
	{
		Box(1,22,4,22,5,dark_gray on light_yellow,2,dark_cyan on light_cyan);
		text(black on light_gray);
		gotoXY(12,28, "ARROWS TO SCROLL - ENTER TO SELECT ELEMENT - ESC TO EXIT.");
		for(int a=0;a<118;a++)
		{
			gotoXY(Number[a].x,Number[a].y);
			text(black on light_cyan);
			cout << Number[a].Symbol;
			if(i==Number[a].x && j == Number[a].y)
			{
				text(dark_gray on light_yellow);
				gotoXY(33-(Element_Group[Number[a].Element_Type].length()/2),5,Element_Group[Number[a].Element_Type]);
				gotoXY(33-(State[Number[a].Element_State].length()/2),6,State[Number[a].Element_State]);
				gotoXY(33-(Number[a].Name.length()/2),7, Number[a].Name);
				gotoXY(Number[a].x,Number[a].y);
				text(light_red on light_cyan);
				cout << Number[a].Symbol;
				Num = Number[a].Atomic_Number-1;
			}
		}
		gotoXY(i,j);
		g =_getch();
		switch(g)
		{
		case ESC:
			return;
		case DOWN:
			{
				if(j+2 <=23)
					j+=2;
				if(j==19)
				{
					if(i<25)
						i=25;
					j+=2;
				}
				break;
			}
		case RIGHT:
			{
				if(j==5 && i==13)
				{
					i=64;
					break;
				}
				if((j>5 && j<=9) && i==16)
				{
					i=49;
					break;
				}
				if(j>=11 || ((j>=7 && j<=9) && (i>=13 && i<16)) ||  ((j>=7 && j<=9) && (i>=49 && i<64)) )
				{
				if(i+3<=64)
					i+=3;
				}
				break;
			}
		case LEFT:
			{
				if(j==5 && i==64)
				{
					i=13;
					break;
				}
				if((j>5 && j<=9) && i==49)
				{
					i=16;
					break;
				}
				if(j>=11 || ((j>=7 && j<=9) && (i>13 && i<=16)) ||  ((j>=7 && j<=9) && (i>49 && i<=64)) )
				{
					if(i-3 >=13 && j<18)
					i-=3;
				else
					if(i-3 >=25 && j>18)
						i-=3;
				}
				break;
			}
		case UP:
			{
				if(j>11 || ((j>7 && i>=13 && i<=16) ||  (j>7 && (i>=49 && i<=64) )) || i==13 && j==7 || i==64 && j==7 )
				{
					if(j-2 >= 5 )
					j-=2;
				if(j==19)
					j-=2;
				}
				break;
			}
		case ENTER:
			{
				Show_Element(Number, Num, i, j );
			}
		} 
	} while(g!=ESC);
}
Last edited on
Here is part two
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
void welcome_screen()
{
	clrscr();
	int x;
	for(x = 45;x> 24;x--)
	{
		Sleep(150);
		gotoXY(x,11,"E L E M E N T  P R O J E C T ");
		gotoXY(x+3,13,"D E V E L O P E D  B Y  : ");
		gotoXY(x+10,15,"whitenite1 ");
	}
}

void Fill_Vector(vector< Element >& Number, ifstream& ElementStream)
{
	Element Atomic;
	Number.clear();

	while(  ElementStream  )
	{
		ElementStream >> Atomic.Atomic_Number;
		ElementStream >> Atomic.x;
		ElementStream >> Atomic.y;
		ElementStream >> Atomic.Symbol;
		ElementStream >> Atomic.Name;
		ElementStream >> Atomic.Atomic_Weight;
		ElementStream >> Atomic.Melting_Point;
		ElementStream >> Atomic.Boiling_Point;
		ElementStream >> Atomic.Density;
		ElementStream >> Atomic.Discovery_Year;
		ElementStream >> Atomic.Ionization_Energy;
		ElementStream >> Atomic.Element_Type;
		ElementStream >> Atomic.Element_State;
		Number.push_back(Atomic);
	}
	ElementStream.close();
}

void Show_Element(vector< Element >& Number, int number, int x, int y )
{
	string Renew[6]={
		"\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4 ",
		" \xB3                             \xB3  \xB3  \xB3  \xB3  \xB3  ",
		"\xC4\xB4                             \xC3\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4",
		" \xB4                             \xC3  \xC5  \xC5  \xC5  \xC5  ",
		"\xC4\xB4                             \xC3\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4",
		"\xC4\xC5\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC2\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4\xC5\xC4\xC4"
	};
	text(black on light_gray);
	string bar(6,'\xC4');
	string rub(57,' ');
	gotoXY(12,28, rub);

	gotoXY(28,28, "Press Any Key To Return....");
	text(black on dark_cyan);
	for (int i = 8;i<22;i+=2)
	{
		gotoXY(62,i,"\xC4");
		gotoXY(62,i+1," ");
	}
	
	gotoXY(18,22,bar);
	for(int i=24;i<61;i+=3)
		gotoXY(i,22,"\xC5\xC4\xC4");
	string In_Shadow[]={"l","r"," ","t","s"," ","b"};
	int p=0;
	for(int i=9;i<=21;i+=2)
	{
		gotoXY(62,i);
		if(x==61 && y==i) // You're viewing an element that now is in a shadow
		{
			text(dark_red on dark_cyan); // Print letter in dark red
			cout << In_Shadow[p];
		}
		else
		{
			text(black on dark_cyan); // Otherwise, print letter in black
			cout << In_Shadow[p];
		}
		p++;
	}
	
	Box(2, 17, 7, 45, 15,black on light_gray, 0,0,0);
	
	gotoXY(21,8,"Element Name            :  ");
	cout << Number[number].Name;
	
	gotoXY(21,9,"Element Symbol          :  ");
	if(  number == 112 || number == 114 || number == 116 || number == 117)
		cout << "U";
	cout << Number[number].Symbol;

	gotoXY(21,11,"Atomic Number           :  ");
	cout << Number[number].Atomic_Number;
	
	gotoXY(21,12,"Relative Atomic Mass    :  ");
	if(  Number[number].Atomic_Weight == 0)
		cout << "[ Unknown ]";
	else
		cout  << fixed << setprecision(4) << Number[number].Atomic_Weight;
		cout  << fixed << setprecision(0);
			
	gotoXY(21,14,"Melting Point (Celcius) :  ");
	if(  Number[number].Melting_Point == 0)
		cout << "[ Unknown ]";
	else
		cout << Number[number].Melting_Point  << "\xF8";

	gotoXY(21,15,"Boiling Point (Celcius) :  ");
	if(  Number[number].Boiling_Point == 0)
		cout << "[ Unknown ]";
	else
		cout << Number[number].Boiling_Point << "\xF8";
	
	gotoXY(21,17,"Density (g/cm^3)        :  ");
	if(  Number[number].Density == 0)
		cout << "[ Unknown ]";
	else
		cout  << fixed << setprecision(2) << Number[number].Density;
	
	gotoXY(21,18,"Ionization Energy       :  ");
	if(  Number[number].Ionization_Energy == 0)
		cout << "[ Unknown ]";
	else
		cout   << fixed << setprecision(4) << Number[number].Ionization_Energy;
	
	cout  << fixed << setprecision(0);
	
	gotoXY(21,20,"Year Of Discovery       :  ");
	if ( Number[number].Discovery_Year == 0)
		cout << "\bAncient Times";
	else
		cout << Number[number].Discovery_Year;
	
	char key;
	key=_getch();
	text(black on light_cyan);
	gotoXY(17,10,Renew[5]);
	for( int i=11;i<18;i+=2)
	{
		gotoXY(17,i);
	   for(int j=0;j<16;j++)
		   cout << " \xB3 ";
		gotoXY(17,i+1);
	   for(int j=0;j<16;j++)
		   cout << "\xC4\xC5\xC4";
	}
	gotoXY(17,7,Renew[1]);
	gotoXY(17,8,Renew[2]);
	gotoXY(17,9,Renew[1]);
	gotoXY(17,18);
	for(int j=0;j<16;j++)
		   cout << "\xC4\xC1\xC4";
	gotoXY(12,19,rub);
	gotoXY(17,20,"\xC4\xC4\xC4\xC4\xC4\xC4");
	 for(int j=0;j<14;j++)
		   cout << "\xC4\xC2\xC4";
	gotoXY(17,21);
	   for(int j=0;j<16;j++)
		   cout << " \xB3 ";
	 gotoXY(17,21,"hanides");
	 gotoXY(17,22,"\xC4\xC4\xC4\xC4\xC4\xC4");
	 for(int j=0;j<14;j++)
		   cout << "\xC4\xC5\xC4";
	 for(int i=3;i<118;i++)
		gotoXY(Number[i].x, Number[i].y, Number[i].Symbol);
	 
	 Console::SetWindowSize(width, height );
}

void Box(int style, int across, int down, int amount, int rows, int f_color, int b_color, int shadow, int shadow_fc, int shadow_bc)
{
	char Shadow[4] = { ' ','\xB0','\xB1','\xB2' };

	char  Style[5][7] = { 
		{' ',' ',' ',' ',' ',' ',' ' },
		{' ','\xDA','\xC4','\xBF','\xB3','\xC0','\xD9'},
		{' ','\xC9','\xCD','\xBB','\xBA','\xC8','\xBC'},
		{' ','\xD5','\xCD','\xB8','\xB3','\xD4','\xBE'},
		{' ','\xD6','\xC4','\xB7','\xBA','\xD3','\xBD'}
	};

	int x;
	string BoxLine(amount-2, Style[style][2]);
	string BoxBody(amount-2, ' ');
	string ShadowLine(amount, Shadow[shadow]);
	
	gotoXY(across,down);
	text(f_color on b_color);
	cout << Style[style][1] << BoxLine << Style[style][3];
	for (x=1; x<rows; x++)
	{
		gotoXY(across,down+x);
		cout << Style[style][4] << BoxBody << Style[style][4];
		if (shadow)
		{
			text(shadow_fc on shadow_bc);
			cout << Shadow[shadow];
			text(f_color on b_color);
		}
	}
	gotoXY(across,down+rows-1);
	cout << Style[style][5] << BoxLine <<  Style[style][6];
	if (shadow)
	{
		text(shadow_fc on shadow_bc);
		cout << Shadow[shadow];
		gotoXY(across+1,down+rows);
		cout << ShadowLine;
		text(f_color on b_color);
	}
}

void text(int text_color on int paper_color)
{
	int color = (text_color+(paper_color*16));
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color );
}
Last edited on
And lastly, the third part..
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
void clrscr()
{
	DWORD n;
	DWORD size;
	COORD coord = {0};
	CONSOLE_SCREEN_BUFFER_INFO csbi;
	HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
	GetConsoleScreenBufferInfo ( h, &csbi );
	size = csbi.dwSize.X * csbi.dwSize.Y;
	FillConsoleOutputCharacter ( h, TEXT ( ' ' ), size, coord, &n );
	GetConsoleScreenBufferInfo ( h, &csbi );
	FillConsoleOutputAttribute ( h, csbi.wAttributes, size, coord, &n );
	SetConsoleCursorPosition ( h, coord );
}

void gotoXY(int x, int y) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition); 
}

void gotoXY(int x, int y, string text) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition);
	cout << text;
}

void setcursor(bool visible, DWORD size) // set bool visible = 0 - invisible, bool visible = 1 - visible
{
	if(size == 0)
	{
		size = 20;	// default cursor size
	}
	CONSOLE_CURSOR_INFO lpCursor;	
	lpCursor.bVisible = visible;
	lpCursor.dwSize = size;
	SetConsoleCursorInfo(console,&lpCursor);
}

void WaitKey()
{
	cout << "Press any key to close this program";
while (_kbhit()) _getch(); // Empty the input buffer
_getch(); // Wait for a key
while (_kbhit()) _getch(); // Empty the input buffer (some keys sends two messages)
}
Last edited on
I can see that you used the GotoXY function (from a post which I made (and you answered to)) (I love that function) and the concol.h library from an article (I have so much fun with that).

Some problems:

1. Console has not been declared.
2. Main must return int.
3. System is not a namespace.

4. When I delete all the Console::SetWindowSize(...);, then fix void main to int main, the delete using namespace System;, your program works beautifully. Nice job! (Show your science teacher, get some extra credit.)
Last edited on
@usandfriends

Did you copy and paste all three of the program above into one file? Then copied the text file and place it in the directory that has the cpp program? I've been using this program since I wrote it, and haven't had those problems you described. I guess I could change void main() to int main(), but everything else in the program works. Hopefully it's just a copy/paste problem

EDIT:
Sorry usandfriends. I am not in school. I'm a retired, 62 year old guy, that likes programming
Last edited on
No, I copied everything into one file, and saved the .txt file also. (main can never be void). Oh, sorry, haha.
@usandfriends

Glad to see that you got it working on your machine. I am looking for ways to improve it, or correct any mistakes in data, or even update the info if someone finds more recent data concerning the elements.

System is a C++/CLI (.Net) namespace.
So, is there any way to improve my program? How about any corrections to the element data? Or, should I just be happy with the way it is now?
You should be more than happy.
EDIT: Can I keep your program?
Last edited on
@usandfriends

Yep. Feel free to keep it. Add on to it, also, if you wish. I'm quite proud of it, and am thrilled anyone would want to use it.
Last edited on
Topic archived. No new replies allowed.