yash agarwal ,3rd year bca ,project on c++ language

27

Upload: dezyneecole

Post on 11-Apr-2017

89 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Yash Agarwal ,3rd Year BCA ,Project on C++ Language
Page 2: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

C++ Programming Assessment

A WORK REPORT SUBMITTED

IN PARTIAL FULLFILLMENT OF THE REQUIREMENT FOR THE DEGREE

Bachelor of Computer Application

Dezyne E’cole College

106/10, CIVIL LINES

AJMER

RAJASTHAN - 305001 (INDIA)

(AUGUST, 2015)

www.dezyneecole.com

SUBMITTED BY Yash Agarwal CLASS: BCA 2nd YEAR

Page 3: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

PROJECT ABSTRACT

I am Yash Agarwal Student of 2nd year doing my Bachelor Degree in Computer Application.

In the following pages I gave compiled my work learnt during my 2nd year at college. The subject

is C++ Programming Language. We are taking an example of Restaurant, There are menu lists is

displayed by the restaurant manager. Whenever the customer will go there restaurant he/she

can choose one or more recipes’ / items from the menu lists is restaurant.

The Following code represent is based on menu driven programming concept that are based on

concept of menus that are perform and executed at run time. This code represent as a converter

to convert the number into the respective following bases. Menu driven programming concept

that represent the list at run time and asked for the respective following input from the menu list

by the user at run time and after it will take

input and process to convert into the respective number conversion bases and generate the

desired output to the user.

Here in the following assessment we are performing the following operations:

1. To Addition Data.

2. To Show data.

3. To Deletion.

4. To Modification.

5. To Search Data.

6. To Exit.

The above conversion represent the menu list that are based on Menu Driven C++ Programming

Concept.

Page 4: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

void front()

{

struct date d;

getdate(&d);

gotoxy(64,1);

printf("%d/%d/%d",d.da_day,d.da_mon,d.da_year);

textcolor(15);

gotoxy(25,15);

cprintf("%c",200);

gotoxy(25,7);

cprintf("%c",201);

gotoxy(55,7);

cprintf("%c",187);

gotoxy(55,15);

cprintf("%c",188);

textcolor(0);

for(i=26;i<=54;i++)

{

gotoxy(i,7);

cout<<char(205);

Page 5: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

gotoxy(i,15);

cout<<char(205);

}

for(i=8;i<=14;i++)

{

gotoxy(25,i);

cout<<char(186);

gotoxy(55,i);

cout<<char(186);

}

gotoxy(34,8);

cprintf("1. - ADD");

gotoxy(34,9);

cprintf("2. - SHOW");

gotoxy(34,10);

cprintf("3. - DELETE");

gotoxy(34,11);

cprintf("4. - MODIFY");

gotoxy(34,12);

cprintf("5. - SEARCH");

gotoxy(34,13);

cprintf("6. - EXIT");

intro();

}

Page 6: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

void add()

{

clrscr();

heading();

front1();

li=fopen("limit.txt","r");

{

fscanf(li,"%d",&l);

}

fclose(li);

if(l<0 || l>100)

{

l=0;

li=fopen("limit.txt","w");

{

fprintf(li,"%d",l);

}

fclose(li);

}

f=fopen("sms.txt","a");

Page 7: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

gotoxy(2,5);

fscanf(stdin,"%d",&id);

fprintf(f,"%d\t",id);

gotoxy(13,5);

fscanf(stdin,"%s",name);

fprintf(f,"%s\t",name);

gotoxy(28,5);

fscanf(stdin,"%s",clas);

fprintf(f,"%s\t",clas);

gotoxy(42,5);

fscanf(stdin,"%s",dob);

fprintf(f,"%s\t",dob);

gotoxy(56,5);

fscanf(stdin,"%s",city);

fprintf(f,"%s\t",city);

gotoxy(68,5);

fscanf(stdin,"%s",phn);

fprintf(f,"%s\n",phn);

l++;

gotoxy(25,10);

cout<<"YOUR ADDITION IS SUCCESS";

getch();

li=fopen("limit.txt","w");

{

Page 8: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

fprintf(li,"%d",l);

}

fclose(li);

fclose(f);

}

void show()

{

clrscr();

f=fopen("sms.txt","a");

fclose(f);

li=fopen("limit.txt","r");

{

fscanf(li,"%d",&l);

}

fclose(li);

if(l<0 || l>100)

{

l=0;

li=fopen("limit.txt","w");

Page 9: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

{

fprintf(li,"%d",l);

}

fclose(li);

f=fopen("sms.txt","w");

fclose(f);

}

f=fopen("sms.txt","r");

heading();

front1();

for(i=0,j=5;i<l;i++,j++)

{

gotoxy(2,j);

fscanf(f,"%d\t",&id);

fprintf(stdout,"%d",id);

gotoxy(13,j);

fscanf(f,"%s\t",name);

fprintf(stdout,"%s",name);

gotoxy(28,j);

fscanf(f,"%s\t",clas);

fprintf(stdout,"%s",clas);

gotoxy(42,j);

fscanf(f,"%s\t",dob);

fprintf(stdout,"%s",dob);

gotoxy(56,j);

fscanf(f,"%s\t",city);

fprintf(stdout,"%s",city);

gotoxy(68,j);

fscanf(f,"%s\n",phn);

fprintf(stdout,"%s",phn);

Page 10: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

}

fclose(f);

}

void modify()

{

clrscr();

int n;

char na[40];

li=fopen("limit.txt","r");

{

Page 11: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

fscanf(li,"%d",&l);

}

fclose(li);

end=l;

heading();

front1();

fp=fopen("temp.txt","w");

f=fopen("sms.txt","r");

gotoxy(32,9);

cout<<"Enter id= ";

cin>>n;

gotoxy(32,11);

cout<<"Enter name= ";

cin>>na;

clrscr();

heading();

front1();

for(i=0;i<end;i++)

{

fscanf(f,"%d\t",&id);

fscanf(f,"%s\t",name);

fscanf(f,"%s\t",clas);

fscanf(f,"%s\t",dob);

fscanf(f,"%s\t",city);

fscanf(f,"%s\n",phn);

if(n==id && strcmp(na,name)==0)

{

gotoxy(2,5);

fscanf(stdin,"%d",&id);

fprintf(fp,"%d\t",id);

Page 12: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

gotoxy(13,5);

fscanf(stdin,"%s",name);

fprintf(fp,"%s\t",name);

gotoxy(28,5);

fscanf(stdin,"%s",clas);

fprintf(fp,"%s\t",clas);

gotoxy(42,5);

fscanf(stdin,"%s",dob);

fprintf(fp,"%s\t",dob);

gotoxy(56,5);

fscanf(stdin,"%s",city);

fprintf(fp,"%s\t",city);

gotoxy(68,5);

fscanf(stdin,"%s",phn);

fprintf(fp,"%s\n",phn);

gotoxy(25,10);

cout<<"YOUR MODIFICATION IS SUCCESS";

}

else

{

fprintf(fp,"%d\t",id);

fprintf(fp,"%s\t",name);

fprintf(fp,"%s\t",clas);

fprintf(fp,"%s\t",dob);

Page 13: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

fprintf(fp,"%s\t",city);

fprintf(fp,"%s\n",phn);

}

}

fclose(f);

fclose(fp);

remove("sms.txt");

rename("temp.txt","sms.txt");

}

void del()

{

Page 14: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

int n;

char na[40];

clrscr();

li=fopen("limit.txt","r");

{

fscanf(li,"%d",&l);

}

fclose(li);

end=l;

heading();

front1();

fp=fopen("temp.txt","w");

f=fopen("sms.txt","r");

gotoxy(32,9);

cout<<"Enter id= ";

cin>>n;

gotoxy(32,11);

cout<<"Enter name= ";

cin>>na;

clrscr();

front1();

heading();

for(i=0;i<end;i++)

{

fscanf(f,"%d\t",&id);

fscanf(f,"%s\t",name);

fscanf(f,"%s\t",clas);

fscanf(f,"%s\t",dob);

fscanf(f,"%s\t",city);

fscanf(f,"%s\n",phn);

Page 15: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

if(n==id && strcmp(na,name)==0)

{

l=l-1;

li=fopen("limit.txt","w");

{

fprintf(li,"%d",l);

}

fclose(li);

gotoxy(25,14);

cout<<"YOUR DELETION IS SUCCESS";

}

else

{

fprintf(fp,"%d\t",id);

fprintf(fp,"%s\t",name);

fprintf(fp,"%s\t",clas);

fprintf(fp,"%s\t",dob);

fprintf(fp,"%s\t",city);

fprintf(fp,"%s\n",phn);

}

}

fclose(f);

fclose(fp);

remove("sms.txt");

rename("temp.txt","sms.txt");

}

Page 16: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

void search()

{

int n;

clrscr();

li=fopen("limit.txt","r");

{

fscanf(li,"%d",&l);

}

fclose(li);

end=l;

heading();

Page 17: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

front1();

f=fopen("sms.txt","r");

gotoxy(32,12);

cout<<"Enter id= ";

cin>>n;

clrscr();

heading();

front1();

for(i=0;i<end;i++)

{

fscanf(f,"%d\t",&id);

fscanf(f,"%s\t",name);

fscanf(f,"%s\t",clas);

fscanf(f,"%s\t",dob);

fscanf(f,"%s\t",city);

fscanf(f,"%s\n",phn);

if(n==id)

{

gotoxy(2,5);

fprintf(stdout,"%d\t",id);

gotoxy(13,5);

fprintf(stdout,"%s\t",name);

gotoxy(28,5);

fprintf(stdout,"%s\t",clas);

gotoxy(42,5);

fprintf(stdout,"%s\t",dob);

gotoxy(56,5);

fprintf(stdout,"%s\t",city);

gotoxy(68,5);

fprintf(stdout,"%s\n",phn);

Page 18: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

}

}

fclose(f);

}

void heading()

{

for(i=1;i<=80;i++)

{

gotoxy(i,2);

cout<<"-";

gotoxy(i,4);

cout<<"-";

}

gotoxy(2,3);

cout<<"ID";

gotoxy(13,3);

cout<<"Name";

gotoxy(28,3);

cout<<"Class";

gotoxy(42,3);

cout<<"D O B";

gotoxy(56,3);

cout<<"City";

gotoxy(68,3);

cout<<"Phone Number";

}

Page 19: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

void front1()

{

for(i=2;i<=79;i++)

{

textbackground(7);

gotoxy(i,25);

cprintf(" ");

}

struct date d;

getdate(&d);

gotoxy(66,1);

printf("%d/%d/%d",d.da_day,d.da_mon,d.da_year);

textcolor(0);

gotoxy(2,25);

cprintf("1. - ADD");

gotoxy(13,25);

cprintf("2. - SHOW");

gotoxy(25,25);

cprintf("3. - DELETE");

gotoxy(39,25);

cprintf("4. - MODIFY");

gotoxy(54,25);

cprintf("5. - SEARCH");

gotoxy(68,25);

cprintf("6. - EXIT");

textbackground(6);

}

Page 20: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

void intro()

{

gotoxy(60,20);

cout<<"Yash Agarwal";

gotoxy(60,21);

cout<<"BCA 2nd Year";

gotoxy(60,22);

cout<<"~~~~~~~~~~~~~~";

}

};

void design()

{

for(i=0;i<=25;i++)

{

for(j=0;j<=80;j++)

{

textbackground(6);

gotoxy(j,i);

cprintf(" ");

}

}

}

void head()

{

gotoxy(25,5);

textcolor(15);

Page 21: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

cprintf("Student Management System (S M S)");

textcolor(0);

}

void main()

{

clrscr();

sms ss;

int p,i,j;

char ld[40],ps[5],ch;

if(run==1)

{

for(i=0;i<=25;i++)

{

for(j=0;j<=80;j++)

{

textbackground(6);

gotoxy(j,i);

cprintf(" ");

}

Page 22: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

}

textcolor(0);

gotoxy(27,10);

cprintf("Login Id");

for(p=27;p<48;p++)

{

gotoxy(p,11);

textbackground(7);

cprintf(" ");

}

textbackground(6);

gotoxy(27,13);

cprintf("Login Password");

for(p=27;p<48;p++)

{

gotoxy(p,14);

textbackground(7);

cprintf(" ");

}

textcolor(0);

gotoxy(41,11);

cprintf("@hy.app");

gotoxy(27,11);

scanf("%s",ld);

gotoxy(27,14);

p=0;

while(1)

Page 23: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

{

ch=getch();

if(ch==13)

{

break;

}

ps[p]=ch;

p++;

cprintf("*");

}

run++;

textbackground(0);

if((strcmp(ld,"hello")==0))

{

if(ps[0]=='t' && ps[1]=='a' && ps[2]=='r' && ps[3]=='u' && ps[4]=='n')

{

clrscr();

ss.design();

textcolor(0);

ss.head();

ss.front();

ch=getch();

do

{

if(ch=='1')

{

ss.add();

}

else if(ch=='2')

{

Page 24: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

ss.show();

}

else if(ch=='3')

{

ss.del();

}

else if(ch=='4')

{

ss.modify();

}

else if(ch=='5')

{

ss.search();

}

else if(ch=='6')

{

exit(0);

}

else

{

main();

}

ch=getch();

}while(ch);

}

else

{

exit(0);

}

Page 25: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

}

else

{

exit(0);

}

}

else

{

for(i=0;i<40;i++)

{

ps[i]=NULL;

}

clrscr();

ss.design();

textcolor(0);

ss.head();

ss.front();

ch=getch();

do

{

if(ch=='1')

{

ss.add();

}

else if(ch=='2')

{

ss.show();

}

else if(ch=='3')

{

Page 26: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

ss.del();

}

else if(ch=='4')

{

ss.modify();

}

else if(ch=='5')

{

ss.search();

}

else if(ch=='6')

{

exit(0);

}

else

{

main();

}

ch=getch();

}while(ch);

}

getch();

}

Page 27: Yash Agarwal ,3rd Year BCA ,Project on C++ Language

Thank You

YASH AGARWAL

Bachelor of Computer Application

Dezyne E’cole College

106/10, CIVIL LINES

AJMER

RAJASTHAN - 305001 (INDIA)

(AUGUST, 2015)

www.dezyneecole.com