chemistry periodic table
this is my source code....
christygity, on 31 December 2012 - 05:21 AM, said:
chemistry periodic table
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<process.h>
#include<fstream.h>
#include<graphics.h>
#include<iomanip.h>
#include<dos.h>
void cdisp();
class periodic
{ public:
char name[50], sym[50];
int atno, groupno, periodno;
float atweight, density, melt, boil, elctrneg, fie, vdw, atr, cor;
void accept(
{;
cout<<"Enter the details:- ";
cout<<"\nName: ";
gets(name);
cout<<"Symbol: ";
cin>>sym;
cout<<"Atomic no: ";
cin>>atno;
cout<<"Group no: ";
cin>>groupno;
cout<<"Period no: ";
cin>>periodno;
cout<<"Atomic weight: ";
cin>>atweight;
cout<<"Dnensity: ";
cin>>density;
cout<<"Melting point: ";
cin>>melt;
cout<<"Boiling point: ";
cin>>melt;
cout<<"Electronegativity: ";
cin>>eletrneg;
cout<<"First ionisation enthalpy: ";
cin>>fie;
cout<<"Atomic radius: ";
cin>>atr;
cout<<"Van der waal's radius: ";
cin>>vdw;
cout<<"Covalent radius: ";
cin>>cor;
}
void display()/*this function is used to display the elements of the periodic table*/
{
gotoxy(40,51);cout<<name<<setw(6);
gotoxy(40,52);cout<<sym<<setw(6);
gotoxy(40,53);cout<<atno<<setw(6);
gotoxy(40,54);cout<<groupno<<setw(6);
gotoxy(40,55);cout<<periodno<<setw(6);
gotoxy(40,56);cout<<atweight<<setw(6);
gotoxy(40,57);cout<<density<<setw(6);
gotoxy(40,58);cout<<melt<<setw(6);
gotoxy(40,59);cout<<boil<<setw(6);
gotoxy(40,60);cout<<electrneg<<setw(6);
gotoxy(40,61);cout<<fie<<setw(6);
gotoxy(40,62);cout<<atr<<setw(6);
gotoxy(40,63);cout<<vdw<<setw(6);
gotoxy(40,64);cout<<cor<<setw(6);
cout<<endl;
getch();
}
void grdisp();
};
void cdisp()
{
clscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
periodic z;
gotoxy(40,65);cout<<"\t\tName"<<"\tSymbol"<<"Atomic no"<<"Group no"<<"Period no"<<endl;
ififstream f2("project.dat",ios::binary);
f2.read((char*&z,sizeof(z));
while(!f2.eof())
{ if(z.atno%10==0)
{getch();
}
}
else
{
gotoxy(40,66); cout<<"\t\t"<<setw(8)<<z.name<<setw(8)<<z.periodno<<endl;
}
f2.read((char*)&z,sizeof(z));
}
f2.close();
getch();
closegraph();
}
void search()/*this function is used to search the elements of periodic table*/
{
int i, ch, sat, flag=0;
char sname[50];
periodic e;
cout<<"Search Menu"<<endl;
cout<<"\n1.Search by atomic no";
cout<<"\n2.Search by name";
cout<<"\nEnter choice: ";
cin>>ch;
switch(ch)
{
case 1: cout<<"\nSearch by atomic number";
cout<<"\nEnter atomic number to be searched: ";
cin>>sat;
ifstream f2("project.dat",ios::binary);
f2.read((char*)&e,sizeof(e));
while(!f2.eof())
{if(sat==e.atno)
{flag=1;
break;
}
f2.read((char*)&e,sizeof(e));
}
f2.close();
if(flag==1)
e.grdisp();
else
{cout<<"\nElement not found!!!";
getch();}
break;
case 2: cout<<"\nSearch by name of the element';
cout<<"\nEnter the name of the element to be searched: ";
cin>>sname;
ifstream f3("project.dat",ios::binary);
f3.read((char*)&e,sizeof(e));
while(!f3.eof())
{
if(strcmp(sname,e.name)==0)
{flag=1;
break;}
f3.read((char*)&e,sizeof(e));
}
f3.close();
if(flag==1)
e.grdisp();
else
{
cout<<"\nElement not found!!!";
getch();}
break;
default: cout<<"\nWrong choice";
}
}
void add()/*this function is used to add elements into the periodic table*/
{
periodic f;
int n=0;
clrscr();
cout<<"\nEnter the no of enteries";
cin>>n;
ofstream f1("project.dat",ios::binary|ios::app);
for(int i=0;i<n;i++)
{f.accept();
f1.write((char*)&f,sizeof(f));
}
f1.close();
}
void del()/*this function is used to delete the elements from the periodic table table*/
{
clrscr();
inti, ch1, dat, flag=0;
char dname[50];
periodic q;
cout<<"\nDelete Menu";
cout<<"\n1.Delete by atomic no";
cout<<"\n2.Delete by name";
cout<<"\nEnter Choice: ";
cin>>ch1;
switch(ch1)
{
case1: cout<<"\nDelete by atomic number of element";
cout<<"\nEnter atomic no of the element to be deleted: ";
cin>>dat;
ifstream f6("project.dat",ios::binary);
ofstream f7("temp.dat",ios::binary);
f6.read((char*)&q,sizeof(q));
while(!f6.eof())
{
if(dat==q.atno)
{flag=1;
break;
}
f6.read((char*)&q,sizeof(q));
}
if(flag==1)
{ f6.seekg(0,ios::beg);
f6.read((char*)&q,sizeof(q));
while(!f6.eof())
{
if(dat!=q.atno)
{
f7.write((char*)&q,sizeof(q));
}
f6.read((char*)&q,sizeof(q));
}
f6.close();
f7.close();
remove("project.dat");
rename("temp.dat","project.dat");
cout<<"The element is deleted!!!";
getch();
}
else
{
cout<<"Element not found!!!!":
getch();
}
break;
case 2: cout<<"Delete by name of element";
cout<<"\nEnter nameto be deleted: ";
gets(dname);
ifstream f4("project.dat",ios::binary);
ofstream f5("temp.dat",ios::binary);
f4.read((char*)&q,sizeof(q));
while(!f4.eof())
{
if (strcmp1(dname,q.name)==0)
{
flag=1;
break;
}
f4.read((char*)&q,sizeof(q);
}
if(flag==1)
{ f4.seekg(0,ios::beg);
f4.read((char*)&q,sizeof(q));
while(if4.eof())
{
if(strmpi(dname,q.name)!=0)
{
f5.write((char*)&q,sizeof(q));
}
f4.read((char*)&q,sizeof(q);
}
f4.close();
f5.close();
remove("project.dat"0;
rename("temp.dat","project.dat"};
gotoxy(40,94);cout<<"Element is deleted!!!";
getch();
|
else{
gotoxy(40,95);cout<<"Element not found!!!";
getch();}
break;
default: gotoxy(40,96);cout<<"\nwrong choice";
}
}
void modify()/*this function is used to modify the elements in the periodic table*/
{
periodic g;
int mat,i,flag=0;
cout<<"Modify by atomic no;";
cout<<"\nEnter atomic no: to be modified: ";
cin>>mat;
ifstream f8("project.dat",ios::binary);
ofstream f9("temp.dat",ios::binary);
f8.read((char*)&g,sizeof(g));
while(!f8.eof())
{
if(mat==g.atno)
{clrscr();
g.accept();
f9.write((char*)&g,sizeof(g));
flag=1;
}
else
f9.write((char*)&g,sizeof(g));
f8.read((char*)&g,sizeof(g));
}
f8.close();
f9.close();
remove("project.dat");
rename("temp.dat","project.dat");
if(flag==1)
{clrscr();
gotoxy(40,100); cout<<"Element is modified!!!";}
getch();
}
void periodic::grdisp()
{int gd=DETECT, gm;
intgraph(&gd,&gm,"c:\tc");
settextstyle(1,0,2);
setcolor(2);
outtextxy(120,120,"SYMBOL:");
outtextxy(120,136,"Atomic no:");
outtextxy(120,152,"Group no:");
outtextxy(120,168,"Period no:");
outtextxy(120,184,"Atomic weight:");
outtextxy(120,200,"Density:");
outtextxy(120,216,"Melting Point:");
outtextxy(120,232,"Boiling Point:");
outtextxy(120,248,"Electronegativity:");
outtextxy(120,264,"First Enthalpy:");
outtextxy(120,280,"Van der waals Radius:");
outtextxy(120,296,"Atomic Radius:");
outtextxy(120,312,"Covalent Radius:");
setcolor(9);
outtextxy(348,120,sym);
settextstyle(5,0,8);
outtextxy(150,o,name);
gotoxy(45,10);
cout<<atno;
gotoxy(45,11);
cout<<groupno;
gotoxy(45,12);
cout<<periodno;
gotoxy(45,13);
cout<<atweight;
gotoxy(45,14);
cout<<density;
gotoxy(45,15);
cout<<melt;
gotoxy(45,16);
cout<<boil;
gotoxy(45,17);
cout<<electrneg;
gotoxy(45,18);
cout<<fie;
gotoxy(45,19);
cout<<vdw;
gotoxy(45,20);
cout<<atr;
gotoxy(45,21);
cout<<cor;
getch();
closegraph();
}
void table()
{
system("cls");
cout<<" \n\n\t\t\t\t\t\t THE PERIODIC TABLE\n\t\t\t\t\t\t ------------------\n\n";
cout<<" *------------- G R O U P -------------*\n\n";
cout<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 \n";
cout<<" |-----| |----|\n";
cout<<" 1 | 1 | | 2 |\n";
cout<<" * | H | | He |\n";
cout<<" | |-----|-----| |-----|-----|-----|-----|-----|----|\n";
cout<<" | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | 9 | 10 |\n";
cout<<" P | Li | Be | | B | C | N | O | F | Ne |\n";
cout<<" |-----|-----| |-----|-----|-----|-----|-----|----|\n";
cout<<" E 3 | 11 | 12 | | 13 | 14 | 15 | 16 | 17 | 18 |\n";
cout<<" | Na | Mg | | Al | Si | P | S | Cl | Ar |\n";
cout<<" R |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<" 4 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |\n";
cout<<" I | K | Ca | Sc | Ti | V | Cr | Mn | Fe | Co | Ni | Cu | Zn | Ga | Ge | As | Se | Br | Kr |\n";
cout<<" |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<" O 5 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |\n";
cout<<" | Rb | Sr | Y | Zr | Nb | Mc | Tc | Ru | Rh | Pd | Ag | Cd | In | Sn | Sb | Te | I | Xe |\n";
cout<<" D |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<" | 6 | 55 | 56 | * | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |\n";
cout<<" | | Cs | Ba | | Hf | Ta | W | Re | Os | Ir | Pt | Au | Hg | Tl | Pb | Bi | Po | At | Rn |\n";
cout<<" * |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<" 7 | 87 | 88 | ** | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118|\n";
cout<<" | Fr | Ra | | Rf | Db | Sg | Bh | Hs | Mt | Ds | Rg | Cn | Uut | Uuq | Uup | Uuh | Uus | Uuo|\n";
cout<<" |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n\n";
cout<<" |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<" *Lanthanides | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |\n";
cout<<" | Ce | Pr | Nd | Pm | Sm | Eu | Gd | Tb | Dy | Ho | Er | Tm | Yb | Lu |\n";
cout<<" |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<" ** Actinides | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103|\n";
cout<<" | Th | Pa | U | Np | Pu | Am | Cm | Bk | Cf | Es | Fm | Md | No | Lr |\n";
cout<<" |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----|\n";
cout<<endl<<endl;
}
void loading() /*this function is used to display the graphical representation of our table*/
{
int f;
clrscr();
textcolor(10);
gotoxy(30,2);
cputs("PERIODIC TABLE");
gotoxy(25,10);
textcolor(38);
cputs("<<<<<<LOADING THE PROGRAM FILES>>>>>>");
for(int i=1;i<=30;i++)//loop begining
{delay(150);
gotoxy(30,20);
f=i*3.34;
if(f==100)
{{textcolor(153);
cputs("COMPLETED....");
cout<<f<<"%";
}
else
{textcolor(12);
cputs("LOADING...")'
cout<<f<<"%";
gotoxy(24+i,18);
textbackground(GREEN);
//txtcolor(WHITE);
cputs(" ");
textbackground(BLACK);}
textcolor(WHITE);
}
cout<<"\n\n\n\n\n\t\tTo Continue Press Enter....";
getch();
}
void password()/*this is used to give a password to our project*/
{
int i,j;
char uname[20], passw[20];
static int k=0;
do
{clrscr();
gotoxy(26,3);
textcolor(132);
cputs("*****::RESTRICTED ACCESS::*****");
gotoxy(17,5);
cout<<"Please enter the username and password "<<endl;
gotoxy(30,7);
cout<<"USER NAME: ";
gotoxy(30,8);
gets(uname);
gotoxy(30,11);
cout<<"PASSWORD: ";
gotoxy(30,12);
for(i=0;i<=20;i++)
{passw[i]=getch();
if(passw[i]==13)
break;
cout<<"*";
}
passw[i]=o;
{if((strcmpi(uname,"joke-boyes")==0)&&(strcmp(passw,"chrisjusans")==0))
{gotoxy(30,15);
textcolor(146);
cputs("ACCESS GRANTED");
textcolor(WHITE);
getch();
break;
}
else
{gotoxy(23,18);
textcolor(148);
cputs("WRONG USERNAME OR PASSWORD");
textcolor(WHITE);
getch();
k++;
}
}
}
while(k<3);
if(k==3)
{gotoxy(12,20);
textcolor(147);
cputs("YOU HAVE EXCEEDED MAXIMUM NUMBER OF WRONG ENTERIES");
textcolor(WHITE);
getch();
exit(0);
}
}
void loading1()
{
int j;
int gd=DETECT, gm;
initgraph(&gd,&gm,"c:\tc");
settextstyle(5,0,5);
outtextxy(80,100,"..::PERIODIC");
outtextxy(350,100,"TABLE::..");
line(230,330,370,330);
line(230,350,370,350);
line(226,335,226,345);
line(226,335,230,330);
line(226,345,230,350);
line(374,335,374,345);
line(374,335,370,330);
line(374,345,370,350);
settextstyle(0,0,0);
setcolor(19);
outtextxy(273,365,"LOADING");
outtextxy(255,375,"PLEASE");
outtextxy(310,375,"WAIT");
for(int m=0;m<4;m++)
{int x= 232,y=336,x1=236,y1=344;
int x2=232,y2=336,x3=236,y3=344;
for(int i=0;i<26;i++)
{ if(i<23)
{delay(100);
setfillstyle(1,GREEN);
bar(x,y,x1,y1);
x=x1+2;
x1=x1+6;
}
if(i>2)
{
setfillstyle(1,BLACK);
bar(x2,y2,x3,y3);
x2=x3+2;
x3=x3+6;
}
}
}
}
void main()
{
int ch, ch1, st, st1, st2, st3, st4, st5, st6, st7;
int ch2=0;
clrscr();
int gd=DETECT, gm;
initgraph(&gd,&gm,"c:/tc");
int i=0;
while(!kbhit())
{ delay(100);
setcolor(i);
settextstyle(4,0,6);
outtextxy(180,20,"WELCOME");
outtextxy(270,80,"TO");
outtextxy(70,140,"PERIODIC TABLE");
settextstyle(3,0,3);
setcolor(14);
outtextxy(30,300,"PROGRAMERS:");
outtextxy(30,320,"ANSHU GOPI");
outtextxy(30,340,"CHRISTY SHIBU JOHN");
outtextxy(30,362,"JESTIN MEPPURATHU JOHNSON");
settextstyle(2,0,5);
setcolor(2);
outtextxy(300,420,"PLEASE PRESS ANY KEY TO CONTINUE");
i++;
}
getch();
closegraph();
loading1();
do
{clrscr();
st:
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(25,3);
cout<<".::Welcome to Periodic Table::.\n\n";
gotoxy(30,5);
delay(500);
cout<<"1.Add Elements";
gotoxy(30,7);
delay(500);
cout<<"2.Search for Elements";
gotoxy(30,9);
delay(500);
cout<<"3.Display Elements";
gotoxy(30,11);
delay(500);
cout<<"4.Modify an Element";
gotoxy(30,13);
delay(500);
cout<<"5.Delete an Element";
gotoxy(30,15);
delay(500);
cout<<"6.Display the Periodic Table";
delay(30,17);
cout<<"7.Exit";
gotoxy(30,22);
delay(500);
cout<<"Enter your choice(1-7)";
cin>>ch;
closegraph();
switch(ch)
{
case 1: st1:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Add an element";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: add()
break;
case 2:goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st1;
}
closegraph();
break;
case 2: st2:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Search for an element";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: search()
break;
case 2:goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st2;
}
closegraph();
break;
case 3: st3:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Display all the elements";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: cdisp()
break;
case 2:goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st3;
}
closegraph();
break;
case 4: password();
loading();
st4:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Modify an element";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: modify()
break;
case 2:goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st4;
}
closegraph();
break;
case 5: st5:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Delete an element";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: del()
break;
case 2: goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st5;
}
closegraph();
break;
case 6: st6:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Display the Periodic Table";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: table()
break;
case 2: goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st6;
}
closegraph();
break;
case 7: st7:
clrscr();
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
gotoxy(30,2);
cout<<"1.Exit the program";
gotoxy(30,3);
cout<<"2.Return to main menu";
gotoxy(30,4);
cout<<"Enter choice: ";
cin>>ch1;
switch(ch1)
{
case 1: gotoxy(32,6);
cout<<"THANK YOU";
getch();
exit(0);
break;
case 2:goto st;
default: gotoxy(30,6);
cout<<"WRONG CHOICE";;
getch();
goto st7;
}
closegraph();
break;
default: goto st;
}
clrscr()
initgraph(&gd,&gm,"c:/tc");
setbkcolor(LIGHTBLUE);
setcolor(14);
for(int i=5; i>=0; i--)
{gotoxy(30,12);
cout<<"Returning to Main Menu ";
delay(1000);
ch2=i;
gotoxy(36,13);
cout<<ch2<<"seconds";
}
closegraph();
}
while (ch2==0);
getch();
}
this is my source code....