Kirtesh Khandelwal,Final Year BCA , Dezyne E'cole College

23
C++ PROGRAMING ASSIGNMENT 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: KIRTESH KHANDELWAL CLASS: BCA 2 nd YEAR

Transcript of Kirtesh Khandelwal,Final Year BCA , Dezyne E'cole College

C++ PROGRAMING

ASSIGNMENT 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:

KIRTESH KHANDELWAL

CLASS: BCA 2nd YEAR

PROJECT ABSTRACTION

I am KIRTESH KHANDELWAL 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.

The Following code represent is based on Menu Driven Programming Concept

that are based on concept of menus that are perform & executed at run time. This

code represent as a database to store the data of student. Menu driven

Programing concept that represent the (SMS) student management system on

run time & show multiple operations.

This code create using file handling which show the data , addition, modification,

deletion, searching the data.

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

1. To Addition.

2. To show data.

3. To Deletion.

4. To Modification.

5. To Search;

6. To exit.

The above (SMS) Student Management System represents the menu list that is

based on Menu Driven C++ Programming Concept.

In the following pages I am showcasing my work.

Header Files used for following code:

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

#include<graphics.h>

int l=0;

class sms

{

public:

int id,i,k;

char name[30],clas[20],city[20],dob[20],phno[20],ch;

FILE *f,*q,*lvalue,*newl;

void add()

{

newl=fopen("newl.txt","r");

{

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

}

gotoxy(23,10);

cout<<"PREVIOUS ENTRIES::"<<l<<"\n";

l++;

lvalue=fopen("lvalue.txt","w");

{

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

}

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

gotoxy(23,11);

cout<<"Enter id of student:: ";

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

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

gotoxy(23,12);

cout<<"Enter name of student:: ";

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

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

gotoxy(23,13);

cout<<"Enter class of student:: ";

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

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

gotoxy(23,14);

cout<<"Enter city of student:: ";

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

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

gotoxy(23,15);

cout<<"Enter d.o.b of student:: ";

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

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

gotoxy(23,16);

cout<<"Enter phone number of student:: ";

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

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

gotoxy(23,18);

cout<<"Your ADDITION Is Sucess";

newl=fopen("newl.txt","w");

{

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

}

fclose(newl);

fclose(lvalue);

fclose(f);

}

void show()

{

i=3;

clrscr();

lvalue=fopen("lvalue.txt","r");

{

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

}

fclose(lvalue);

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

{

for(k=1;k<=l;k++,i++)

{

gotoxy(4,1);

cout<<"ID";

gotoxy(4,i);

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

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

gotoxy(16,1);

cout<<"NAME";

gotoxy(16,i);

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

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

gotoxy(29,1);

cout<<"CLASS";

gotoxy(29,i);

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

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

gotoxy(42,1);

cout<<"CITY";

gotoxy(42,i);

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

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

gotoxy(54,1);

cout<<"D.O.B";

gotoxy(54,i);

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

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

gotoxy(70,1);

cout<<"PH NO.";

gotoxy(70,i);

fscanf(f,"%s",phno);

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

}

fclose(f);

}

}

void deletion()

{

int ddd,lll;

lvalue=fopen("lvalue.txt","r");

{

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

}

fclose(lvalue);

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

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

lll=l;

gotoxy(27,12);

cout<<"Input ID of Record=";

gotoxy(27,13);

cin>>ddd;

for(k=1;k<=l;k++)

{

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

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

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

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

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

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

if(id==ddd)

{

lll--;

lvalue=fopen("lvalue.txt","w");

{

fprintf(lvalue,"%d",lll);

}

fclose(lvalue);

newl=fopen("newl.txt","w");

{

fprintf(newl,"%d",lll);

}

fclose(newl);

gotoxy(27,15);

cout<<"DELETION IS SUCCESS";

}

else

{

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

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

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

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

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

fprintf(q,"%s\n",phno);

}

}

fclose(f);

fclose(q);

remove("sms.txt");

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

}

void modify()

{

int modi;

lvalue=fopen("lvalue.txt","r");

{

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

}

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

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

gotoxy(23,9);

cout<<"Enter ID of Record=";

gotoxy(23,10);

cin>>modi;

for(k=1;k<=l;k++)

{

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

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

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

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

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

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

if(id==modi)

{

gotoxy(23,11);

cout<<"Enter id of student:: ";

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

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

gotoxy(23,12);

cout<<"Enter name of student:: ";

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

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

gotoxy(23,13);

cout<<"Enter class of student:: ";

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

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

gotoxy(23,14);

cout<<"Enter city of student:: ";

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

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

gotoxy(23,15);

cout<<"Enter d.o.b of student:: ";

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

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

gotoxy(23,16);

cout<<"Enter phone number of student:: ";

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

fprintf(q,"%s\n",phno);

}

else

{

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

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

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

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

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

fprintf(q,"%s\n",phno);

}

}

gotoxy(23,18);

cout<<"Entry is Modified";

fclose(lvalue);

fclose(f);

fclose(q);

remove("sms.txt");

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

}

void search()

{

int sear;

lvalue=fopen("lvalue.txt","r");

{

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

}

fclose(lvalue);

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

gotoxy(27,12);

cout<<"Enter the id of record:: ";

gotoxy(27,13);

cin>>sear;

clrscr();

i=2;

for(k=1;k<=l;k++)

{

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

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

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

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

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

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

if(id==sear)

{

i++;

gotoxy(4,1);

cout<<"ID";

gotoxy(4,i);

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

gotoxy(16,1);

cout<<"NAME";

gotoxy(16,i);

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

gotoxy(29,1);

cout<<"CLASS";

gotoxy(29,i);

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

gotoxy(42,1);

cout<<"CITY";

gotoxy(42,i);

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

gotoxy(54,1);

cout<<"D.O.B";

gotoxy(54,i);

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

gotoxy(70,1);

cout<<"PH NO.";

gotoxy(70,i);

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

gotoxy(18,7);

cout<<"----------------Entry Is Searched---------------";

}

}

fclose(f);

}

void css()

{

int i,j;

char ch;

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

{

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

{

textbackground(9);

cprintf(" ");

}

}

textcolor(15);

gotoxy(25,9);

cprintf("STUDENT MANAGEMENT SYSTEM");

gotoxy(27,11);

cprintf("1.ADD");

gotoxy(27,12);

cprintf("2.SHOW");

gotoxy(27,13);

cprintf("3.REMOVE");

gotoxy(27,14);

cprintf("4.MODIFY");

gotoxy(27,15);

cprintf("5.SEARCH");

gotoxy(27,16);

cprintf("6.EXIT");

box();

}

void footer()

{

textbackground(9);

textcolor(15);

gotoxy(7,25);

cprintf("1.ADD");

gotoxy(17,25);

cprintf("2.SHOW");

gotoxy(28,25);

cprintf("3.REMOVE");

gotoxy(41,25);

cprintf("4.MODIFY");

gotoxy(54,25);

cprintf("5.SEARCH");

gotoxy(67,25);

cprintf("6.EXIT");

}

void box()

{

textbackground(9);

textcolor(15);

for(i=7;i<20;i++)

{

gotoxy(15,i);

cprintf("%c",155);

gotoxy(66,i);

cprintf("%c",155);

}

for(i=15;i<64;i+=3)

{

gotoxy(i,20);

cprintf("%c++",155);

gotoxy(i,6);

cprintf("%c++",155);

if(i==63){

gotoxy(66,20);

cprintf("%c",155);

gotoxy(66,6);

cprintf("%c",155);

}

}

gotoxy(57,22);

cprintf("KIRTESH KHANDELWAL");

gotoxy(59,23);

cprintf("BCA PART 2");

}

};

void main()

{

clrscr();

char k;

sms s;

textbackground(9);

textcolor(15);

s.css();

k=getch();

do

{

if(k=='1')

{

clrscr();

s.box();

s.footer();

s.add();

k=getch();

}

else if(k=='2')

{

clrscr();

s.show();

s.footer();

k=getch();

}

else if(k=='3')

{

clrscr();

s.box();

s.deletion();

k=getch();

}

else if(k=='4')

{

clrscr();

s.box();

s.modify();

s.footer();

k=getch();

}

else if(k=='5')

{

clrscr();

s.box();

s.search();

s.footer();

k=getch();

}

else if(k=='6')

{

exit(0);

}

else

{

main();

}

}while(k);

getch();

}

THANK YOU SUBMITTED BY

KIRTESH KHANDELWAL

BACHELOR OF COMPUTER APPLICATION

CLASS: BCA 2nd Year

Dezyne E’cole College

(2015-16)

www.dezyneecole.com