return from the visuals after the output

Hi all. I hope you give me some little attention and time, i need someone to rely on to develop my program. My project is periodic table and i am working it on Turbo c++ as a compiler this is the required from my prof. So guys please help me. the function should be:

1.visual (graphics)
2.press any key to continue
3.search an atomic number
4.output of the certain number of element
5.press (key) to return
6.back to 1
7.exit


for the code. i could post it if you ask to. Please help. Thank you!
yes, post your code and give us an idea of what is not working with it.
@daryledevs

After getting the periodic table working, I changed main to
1
2
3
4
5
6
7
8
int main()
{
	display();
	
	gotoxy(20,25);
	_getch(); // For MS Visual C++. Remove the underscore for Turbo C++
	return 0;
}


The program then was doing pretty much as your above list. I would use the arrow keys to put the cursor on an element, pressed 'Enter' and the element info would be in a frame. I press a key, and the periodic table would be re-printed. Pressing 'ESC' ended the program.
@whitenite1, i have found an periodic table like that and there where i got the idea as my design. Now i am figuring how to do that. What should i do sir? or i say where do i place display in my code? (below). Sir sorry for too much asking.
Last edited on
sir! @jonnin here's my code. Help me please... :(
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<dos.h>
#include<fstream.h>

#define r rectangle
#define a outtextxy
#define b settextstyle
#define c setfillstyle
#define d floodfill

int main()
{
 int gm,gd;
 gd=VGA;
 gm=VGAHI;
 initgraph(&gd,&gm,"");
 char p;

 do
 {
 // 1st Line


 /*HYDROGEN (H)*/

 b(2,0,2);a(32,9,"1");b(2,0,5);a(32,17,"H");b(2,0,2);a(32,33,"Hydrogen");

 c(1,4);
 r(30,8,65,48);
 d(31,16,15);

/*LITHIUM (Li)*/

 b(2,0,2);a(32,49,"3");b(2,0,5);a(32,57,"Li");b(2,0,2);a(32,73,"Lithium");

 c(1,5);
 r(30,48,65,89);
 d(31,49,15);

 /* SODIUM (Na) */

 b(2,0,2);a(32,90,"11");b(2,0,5);a(32,98,"Na");b(2,0,2);a(32,114,"Sodium");

 c(1,5);
 r(30,89,65,129);
 d(31,90,15);

 /* Potassium (K) */

 b(2,0,2);a(32,130,"19");b(2,0,5);a(32,138,"K");b(2,0,2);a(31,154,"POTASSIUM");

 c(1,5);
 r(30,129,65,170);
 d(31,130,15);

/* Rubdium (Rb) */

 b(2,0,2);a(32,171,"37");b(2,0,5);a(32,179,"Rb");b(2,0,2);a(32,195,"Rubdium");

 c(1,5);
 r(30,170,65,211);
 d(33,179,15);

 /* Cesium (Cs) */

 b(2,0,2);a(32,212,"55");b(2,0,5);a(32,220,"Cs");b   (2,0,2);a(32,236,"Cesium");

 c(1,5);
 r(30,211,65,252);
 d(31,221,15);

 /* Francium (Fr) */

 b(2,0,2);a(32,253,"87");b(2,0,5);a(32,261,"Fr");b (2,0,2);a(32,277,"Francium");

 c(1,5);
 r(30,252,65,293);
 d(31,253,15);

 // 2nd Line

 /*BERYLLIUM (Be)*/

 b(2,0,2);a(67,49,"4");b(2,0,5);a(67,57,"Be");b(2,0,2);a(67,73,"Beryllium");

 c(1,2);
 r(65,48,100,89);
 d(66,49,15);

 /* Magnesium (Mg) */

 b(2,0,2);a(67,90,"12");b(2,0,5);a(67,98,"Mg");b(2,0,2);a(67,114,"Magnesium");

 c(1,2);
 r(65,89,100,129);
 d(66,90,15);

 /* Calcium (Ca) */

 b(2,0,2);a(67,130,"20");b(2,0,5);a(67,138,"Ca");b(2,0,2);a(67,154,"Calcium");

 c(1,2);
 r(65,129,100,170);
 d(66,139,15);

 /* Strontium (Sr) */

 b(2,0,2);a(67,171,"38");b(2,0,5);a(67,179,"Sr");b(2,0,2);a(67,195,"Stronium");

 c(1,2);
 r(65,170,100,211);
 d(66,171,15);

 /* Barium (Ba) */

 b(2,0,2);a(67,212,"56");b(2,0,5);a(67,220,"Ba");b(2,0,2);a(67,236,"Barium");

 c(1,2);
 r(65,211,100,252);
 d(66,212,15);

/* Radium (Ra) */

 b(2,0,2);a(67,253,"88");b(2,0,5);a(67,261,"Ra");b(2,0,2);a(67,277,"Radium");

 c(1,2);
 r(65,252,100,293);
 d(66,253,15);

 // 3rd Line

  /* SCANDIUM (Sc) */

 b(2,0,2);a(102,130,"21");b(2,0,5);a(102,138,"Sc");b(2,0,2);a(102,154,"Scandium");

 c(1,6);
 r(100,129,135,170);
 d(101,130,15);

/* Ythrium (Y) */

 b(2,0,2);a(102,171,"39");b(2,0,5);a(102,179,"Y");b(2,0,2);a(102,195,"Ythrium");

 c(1,6);
 r(100,170,135,211);
 d(101,171,15);

 // 4th Line


 /* Titanium (Ti) */

 b(2,0,2);a(137,130,"22");b(2,0,5);a(137,138,"Ti");b(2,0,2);a(137,154,"Titanium");

 c(1,6);
 r(135,129,170,170);
 d(136,130,15);


 /* Zirconium (Zr) */

 b(2,0,2);a(137,171,"40");b(2,0,5);a(137,179,"Zr");b(2,0,2);a(137,195,"Zirconium");

 c(1,6);
 r(135,170,170,211);
 d(136,171,15);


 /* Hafnium (Hf) */

 b(2,0,2);a(137,212,"72");b(2,0,5);a(137,220,"Hf");b(2,0,2);a(137,236,"Hafnium");

 c(1,6);
 r(135,211,170,252);
 d(136,212,15);

 /* Rutherfordium (Rf) */

 b(2,0,2);a(137,253,"104");b(2,0,5);a(137,261,"Rf");b(2,0,2);a(137,277,"Rutherfor");b(2,0,2);a(137,285,"dium");

 c(1,6);
 r(135,252,170,293);
 d(136,253,15);
 //5th Line

 /* Vanadium (V) */

 b(2,0,2);a(172,130,"23");b(2,0,5);a(172,138,"V");b(2,0,2);a(172,154,"Vandium");

 c(1,6);
 r(170,129,205,170);
 d(171,130,15);

 gotoxy(1,24);
 cout<<"Press enter to continue...."<<endl;
 cin.ignore();
 
 closegraph();

 clrscr();
 int number;

 printf("Enter the atomic number of element(s):");
 scanf("%d",&number);

 switch (number)
   {

   // starting point of the 1st line

   case 1:
   
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 1";
   gotoxy(21,11);
   cout<<"symbol : H";
   gotoxy(21,12);
   cout<<"Element Name : Hydrogen";

   break;

   case 3:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 3";
   gotoxy(21,11);
   cout<<"Symbol : Li";
   gotoxy(21,12);
   cout<<"Element Name : Lithium";
   break;

   case 11:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 11";
   gotoxy(21,11);
   cout<<"Symbol : Na";
   gotoxy(21,12);
   cout<<"Element Name : Sodium";
   break;

   case 19:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic number : 19";
   gotoxy(21,11);
   cout<<"Symbol : K";
   gotoxy(21,12);
   cout<<"Element Name : Potassium";
   break;

   case 37:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 37";
   gotoxy(21,11);
   cout<<"Symbol : Rb";
   gotoxy(21,12);
   cout<<"Element Name: Rubdium";
   break;

   case 55:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 55";
   gotoxy(21,11);
   cout<<"Symbol : Cs";
   gotoxy(21,12);
   cout<<"Element Name : Cesium";
   break;

   case 87:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 87";
   gotoxy(21,11);
   cout<<"Symbol : Fr";
   gotoxy(21,12);
   cout<<"Element Name : Francium";
   break;

   // end of the 1st line and starting point of 2nd line

   case 4:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic number : 4";
   gotoxy(21,11);
   cout<<"Symbol : Be";
   gotoxy(21,12);
   cout<<"Element Name : Beryllium";
   break;

   case 12:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 12";
   gotoxy(21,11);
   cout<<"Symbol : Mg";
   gotoxy(21,12);
   cout<<"Element Name : Magnesium";
   break;

   case 20:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 20";
   gotoxy(21,11);
   cout<<"Symbol : Ca";
   gotoxy(21,12);
   cout<<"Element Name: Calcium";
   break;

   case 38:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 38";
   gotoxy(21,11);
   cout<<"Symbol : Sr";
   gotoxy(21,12);
   cout<<"Element Name: Strontium";
   break;

   case 56:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 56";
   gotoxy(21,11);
   cout<<"Symbol : Ba";
   gotoxy(21,12);
   cout<<"Element Name: Barium";
   break;

   case 88:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 88";
   gotoxy(21,11);
   cout<<"Symbol : Ra";
   gotoxy(21,12);
   cout<<"Element Name: Radium";
   break;

   // end point of the 2nd line and starting point of the 3rd line

   case 21:
   clrscr();
   gotoxy(21,10);
   cout<<"Atomic Number : 21";
   gotoxy(21,11);
   cout<<"Symbol : Sc";
   gotoxy(21,12);
   cout<<"Element Name: Scandium";
   break;


  

   default:printf("\n invalid choice");
   printf("\n Press 'O' or 'o' to continue... or any key to exit...");
      scanf("%s", &p);


}

   getch();

}
while (p != 'o' || p != 'O');
continue;
}
return 0;
@daryledevs

Sorry. Pretty much everything I was doing to help, was based on a completely different program, than the one your actually making. You pointed us to one program that had a frame described, a display function, etc., but the program you're actually making has none of them. Plus, I'm not using Turbo C++ and therefore cannot actually run your program as written.

Good luck then, as I'm not of any help.

Well, I can help a bit on the above cove, on line 375
It should be while (p != 'o' && p != 'O'); with && and not ||
@whitenite1,
well it's okay and i know you did your best and that's enough. Well sir, Thank you for trying to helping me and godbless! :D
Hi sir @jonnin and sir @whitenite and also @thomson! Thank you very much for trying to help to develop my program. Now, i can program it well! It works now i also make back from the start just like what i wanted to using while loops. Very proud! My no sleep for 3 days are worth it!! Thank you!
ok, that looks like a good start.

what does not work yet, besides the graphics? You should always do the gui/graphics last, it saves rework if you change something important when working on other areas.

@jonnin,

it works well now, i also used cleardevice(); instead clrsclr(); because it gives me white screen which is not totally good. Well, thanks for the tip, i am gonna do first the function. Well anw, @whitenite1, i totally understand now about the display() and frame() haha, too slow to understand, sorry! well @jonnin, sir i have a problem well i am working it out to be my design for my introduction. Would you help me? this is the code:

so my problem here is that on the last of group 8 which is the 8 is keeps repeating like "888....." and dunno how to fix it. any idea sir?

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
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>

void welcome_screen()
{
clrscr();
for(int x=50;x>=20;x--)
{
delay(160);
gotoxy(x,12);
cputs("  P R O J E C T   ");
gotoxy(x,14);
cputs("  D E V E L O P E D  B Y  :  ");
gotoxy(x,16);
cputs("G R O U P 8");
 
}
gotoxy(x,24);
cputs("Press Any Key To Continue....");
getch();

}

int main()
{
 clrscr();
 welcome_screen();
 int gdriver=DETECT,gmode,errorcode;
 initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi");

 welcome_screen();


}
return 0;
}


(I just copy it from the resource and changed after the developed by)
ctto
Last edited on
I do not really understand.
It looks to me like you need that clrscr() inside the for loop, so it would clear and redraw in a sort of animation.

as you have it, it just draws over what you had, and since it is moving backwards, the old 8 is still there. say I want to write 'abc' at location 10, then 9, then 8... etc...

1
2
3
4
you get
        abc
       abcc
      abccc

if you cleared the screen each time, you get
1
2
3
        abc
       abc
      abc


you are writing a fixed length over what is already there, but it does not delete the rest of the line, it just leaves it.
Last edited on
Hi sir @jonnin,

It's fine now Haha!! Clrscr(); didn't work. It just gives me a blankscr and then poof you can it now but the purpose, didn't happen. But what i do is, i add space after the 8 and its okay now. Thank you!
Topic archived. No new replies allowed.