C++ Projects:------

 

Hi! It has taken me a lot of time to understand what a " Project " actually means, what are its objectives, and how one should tackle it. This page is especially written for the students of Computer Science who frequently finds themselves confused about what to write in such a project  which carries say some marks or grade in a school level examination. For professionals it is quite obvious that they are used to "projects" of different sorts and perhaps would do it quite better than me!

Now without wasting much of time lets come to business, here are a few things relevant for creating a project in C++:-

bullet

Either you can write a single program and compile it, or you may link many programs and create the project (here you will have to use the projects menu).

bullet

A project should be a very general one which one can modify to suite his own purpose.

bullet

It should use Class, Functions and File Handling. For professional purposes one can also use Graphics.

bullet

Lastly, it should be efficient in whatever task it is supposed to perform and it should also be user-friendly.

C++ is quite a tough language to write good projects as in practical purposes a lot of Java and Oracle are used nowadays.

That's it, I end it with a sample project which I had written in my school days; it's a very short and simple project about  " Student Management System ".

 

bullet  /* C++ PROJECT ON STUDENT MANAGEMENT SYSTEM */

 




#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>

struct marklist
{
char sub[20];
int mark;
};
class Student
{
char name[20];
char clas[10];
char sec[10];
char roll[10];
struct marklist marks[5];
int total;
float per;
char div[5];
void calculate();
public:
Student();
void add_stud(char*,char*,char*,char*,struct marklist[]);
int disp_stud();
char* get_sub(int);
};
Student::Student()
{
strcpy(name,"");
strcpy(clas,"");
strcpy(sec,"");
strcpy(roll,"");
strcpy(marks[0].sub,"English: ");
strcpy(marks[1].sub,"Physics: ");
strcpy(marks[2].sub,"Chemistry: ");
strcpy(marks[3].sub,"Mathematics: ");
strcpy(marks[4].sub,"Comp.science/bio : ");
for(int i=0;i<5;i++)
marks[i].mark=0;
}


void Student::add_stud(char *n,char *c,char *s,char *r,struct marklist m[])
{
strcpy(name,n);
strcpy(clas,c);
strcpy(sec,s);
strcpy(roll,r);
for(int i=0;i<5;i++)
marks[i].mark=m[i].mark;
calculate();
}

int Student::disp_stud()
{
cout<<"\n_________________________________________________________________\n";
cout<<" Student Record";
cout<<"\n_________________________________________________________________\n";
cout<<"Name: "<<name<<" Class: "<<clas<<" Section: "<<sec<<" Roll No: "<<roll<<endl;
for(int i=0;i<5;i++)
cout<<marks[i].sub<<marks[i].mark<<endl;
cout<<"Total: "<<total<<" Percentage: "<<per<<" Division: "<<div<<endl;
cout<<endl<<endl<<endl<<endl<<endl;
cout<<"press any key to continue......";
getch();
clrscr();
return (1);
}
char* Student::get_sub(int i)
{
return marks[i].sub;
}
void Student::calculate()
{
total=0;
for(int i=0;i<5;i++)
total+=marks[i].mark;
per=(float)total/5;
if(per>60.0)
strcpy(div,"Ist");
else if(per>40.0 && per<60.0)
strcpy(div,"Pass");
else
strcpy(div,"Fail");
}


void main()
{
clrscr();
void add_rec(void);
void disp_rec(void);
cout.precision(2);
int choice=0;
gotoxy(20,10);
cout<<"THIS IS A PROJECT ON STUDENT MANAGEMENT SYSTEM ";
gotoxy(25,20);
cout<<"press any key to continue....";
getch();
while(choice!=3)
{ clrscr();
cout<<"\n Menu\n1. Add Student Details\n2. Display Student Details\n3. Exit\nSelect(1-3)\n";
cin>>choice;
switch(choice)
{
case 1:
add_rec();
break;
case 2:
disp_rec();
break;
case 3:
return;
default:
cout<<"Invalid Option\n";
}
}
}

void add_rec()
{
ofstream fout;
char name[20],clas[10],sec[10],roll[10],ans='y';
struct marklist marks[5];
Student student=Student();
fout.open("student.dat",ios::app|ios::binary);
while(ans=='y')
{
cout<<"Name: ";
cin.ignore();
cin.getline(name,20);
cout<<"Class: ";
cin.getline(clas,10);
cout<<"Section: ";
cin.getline(sec,10);
cout<<"Roll No: ";
cin.getline(roll,10);
cout<<"\nenter the marks for 5 subjects\n";
for(int i=0;i<5;i++)
{
cout<<student.get_sub(i);
cin>>marks[i].mark;
}
student.add_stud(name,clas,sec,roll,marks);
fout.write((char*)&student,sizeof(student));
cout<<"Add another student ?(y/n) ";
cin>>ans;
}
fout.close();
return;
}

void disp_rec()
{
ifstream fin;
Student student;
int count=0;
clrscr();
fin.open("student.dat",ios::binary);
while(fin.read((char*)&student,sizeof(student)))
count+=student.disp_stud();
fin.close();
if(count==0)
cout<<"No Student records\n";
return;
}

 

Hosted by www.Geocities.ws

1