[go: up one dir, main page]

0% found this document useful (0 votes)
68 views25 pages

Project Report: Object-Oriented Programming)

The document is a project report for creating a Student Database Management System using C++. The objectives are to store student records including name, ID, marks in various subjects, calculate totals, and show results. The system uses object-oriented programming concepts like classes, objects, encapsulation, inheritance and polymorphism. Functions are defined to get and display student data, calculate grades, add/modify/search/delete records by reading from and writing to a file.

Uploaded by

riwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views25 pages

Project Report: Object-Oriented Programming)

The document is a project report for creating a Student Database Management System using C++. The objectives are to store student records including name, ID, marks in various subjects, calculate totals, and show results. The system uses object-oriented programming concepts like classes, objects, encapsulation, inheritance and polymorphism. Functions are defined to get and display student data, calculate grades, add/modify/search/delete records by reading from and writing to a file.

Uploaded by

riwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

PROJECT REPORT

1. Introduction:

 C++: C++ is an object-oriented computer language created by notable computer


scientist Bjorne Stroustrop as part of the evolution of the C family of languages. C++
is pronounced "see-plus-plus." It was developed as a cross-platform improvement of
C to provide developers with a higher degree of control over

 OOP (Object-oriented programming): Object Oriented programming (OOP) is a


programming paradigm that relies on the concept of classes and objects. It is used to
structure a software program into simple, reusable pieces of code blueprints (usually
called classes), which are used to create individual instances of objects.

2. Objective:
 To create Student Database Management System program
 To store the record of students
 To store calculate the total marks of students
 To show the results of the student

3. Requirements:
 Abstraction [use of ADT classes] ,
 Encapsulation,
 Inheritance,
 Polymorphism,
 Type conversion,
 Operator Overloading,
 File handling to store data permanently
4. Background Theory

1. Object: Objects are the basic run time entities in an object-oriented system.

2. Class: A class is a user-defined data type that we can use in our program, and it works
as an object constructor, or a "blueprint" for creating objects.

3. Constructor: The constructor can be defined as a class in the same way as that of
normal member functions and can access any of its data members.
4. Encapsulation: This makes the program structure easier to manage because each
object’s implementation and state are hidden behind well-defined boundaries.
5. Polymorphism: This means abstract entities are implemented in multiple ways
according to the message passed.
6. Inheritance: This refers to the hierarchical arrangement of implementation fragments.

7. Type conversion: C++ allows us to convert data of one type to that of another. This is
known as type conversion.
There are two types of type conversion in C++.
a. Implicit Conversion
b. Explicit Conversion (also known as Type Casting)

8. Overloading: If we create two or more members having the same name but different
in number or type of parameter, it is known as C++ overloading.
9. Types of overloading in C++ are:
a. Function overloading
b. Operator overloading

10 . Function Overloading: Function Overloading is defined as the process of having two or


more function with the same name, but different in parameters is known as function
overloading in C++

11. Operators Overloading: Operator overloading is a compile-time polymorphism in which


the operator is overloaded to provide the special meaning to the user-defined data type. 

5. Coding:
/***************************************************

****************************************************

*/

// Header file used in this program

#include<iostream>

#include<fstream>

#include<iomanip>

#include<string.h>

using namespace std;

//Student_Management class declaration

class Student_Management

private:

//Class members

char name[10];

int IDnum;

int oop;

int IT;

int multimedia;

int math;

double percentage;
char grade;

public:

// Class functions

void getdata();

void total();

int getIDnum() const;

void showdata() const;

void showheader() const;

void student_record();

void display_record(int);

void Search_display(int);

void modify_record(int);

void delete_record(int);

void display_result();

};

//class function to get data from the user

void Student_Management::getdata()

cout<<"Enter the student's Name:";

cin.ignore();// ignores the return key pressed

cin.getline(name,10);

cout<<"Enter the student's IDnum:";


cin>>IDnum;

cout<<"Enter the student's oop marks:";

cin>>oop;

cout<<"Enter the student's IT marks:";

cin>>IT;

cout<<"Enter the student's multimedia marks:";

cin>>multimedia;

cout<<"Enter the student's math marks:";

cin>>math;

total();

//class function to calculate total grade

void Student_Management::total()

percentage=(oop+IT+multimedia+math)/4;

//checking the conditions

if(oop>=40 || IT>=40 || multimedia>=40 || math>=40)

if (percentage>=80)

grade='A';

}
else if (percentage>=60)

grade='B';

else if (percentage>=40)

grade='C';

else

grade='F';

else

grade='F';

//class function to show data

void Student_Management::showdata() const

{
cout<<"\nName:"<<name<<endl;

cout<<"ID number:"<<IDnum<<endl;

cout<<"OOP mark:"<<oop<<endl;

cout<<"IT mark:"<<IT<<endl;

cout<<"Multimedia mark:"<<multimedia<<endl;

cout<<"Math mark:"<<math<<endl;

cout<<"Percentage:"<<percentage<<endl;

cout<<"Grade:"<<grade<<endl;

cout<<"Please press any key to continue........\n"<<endl;

// class function for header to show data

void Student_Management::showheader() const

cout<<IDnum<<setw(5)<<"
"<<name<<setw(10)<<oop<<setw(11)<<IT<<setw(15)<<multimedia<<setw(21)<<math<<s
etw(18)<<percentage

<<setw(7)<<grade<<endl<<endl;

// class function to return id number

int Student_Management::getIDnum() const

return IDnum;
}

// function to write and store the record of students

void student_record()

Student_Management S; // object of class

ofstream outFile; //Stream class to write on files

outFile.open("Student_record.txt",ios::binary|ios::app);

S.getdata();

outFile.write(reinterpret_cast<char *>(&S), sizeof(Student_Management));

outFile.close();

cout<<"Student's record has been created.Please press any key to


continue........\n"<<endl;

cin.ignore(); // ignores the return key pressed

//cin.get(); //accessing character array

// function to display all the stored student recored

void display_record()

Student_Management S; // object of class

ifstream inFile; //Stream class to read from files

inFile.open("Student_record.txt",ios::in);
if (!inFile)

cout<<"File could not be created.Please press any key to continue........ " ;

cin.ignore(); // ignores the return key pressed

cin.get(); //accessing character array

return;

while (inFile.read(reinterpret_cast<char *> (&S), sizeof(Student_Management)))

S.showdata();

inFile.close();

cin.ignore();

cin.get();

// function to search the record stored

void display_search(int n)

Student_Management S;

ifstream inFile; //Stream class to read from files


inFile.open("Student_record.txt",ios::in);

if(!inFile)

cout<<"File could not be created.Please press any key to continue........ " ;

cin.ignore();

cin.get();

return;

bool flag=false; // checks the status

while (inFile.read(reinterpret_cast<char *> (&S), sizeof (Student_Management)))

if(S.getIDnum()==n);

S.showdata();

flag = true;

inFile.close();

if (flag==false)

cout<<"\n Record doesnot exist.Please press any key to continue........";

cin.ignore();// ignores the return key pressed


cin.get(); //accessing character array

// function to modify the record stored

void modify_record(int n)

bool flag=false;

Student_Management S;

fstream File; //Stream class to both read and write from/to files

File.open("Student_record.txt",ios::in);

if(!File)

cout<<"File could not be created. " ;

cin.ignore();

cin.get();

return;

while(!File.eof() && flag==false)

File.read(reinterpret_cast<char *> (&S), sizeof (Student_Management));

if ( S.getIDnum()==n)

S.showdata();
cout<<"\n\n Please enter the new details of student"<<endl;

S.getdata();

int pos=(-1)*static_cast<int>(sizeof(S));

File.seekp(pos,ios::cur);

File.write(reinterpret_cast<char *> (&S), sizeof


(Student_Management));

cout<<"\n\n\t The record is updated.Please press any key to


continue........";

flag=true;

File.close();

if(flag==false)

cout<<"\n Sorry! Record not found.Please press any key to continue........";

cin.ignore();// ignores the return key pressed

cin.get(); //accessing character array

// function to delete the record stored

void delete_record(int n)

Student_Management S;
ifstream inFile;

inFile.open("Student_record.txt");

if(!inFile)

cout<<"\n Sorry !!! File could not be open.Please press any key to
continue........ " ;

cin.ignore();// ignores the return key pressed

cin.get(); //accessing character array

return;

ofstream outFile;

inFile.open("delete.txt",ios::out);

inFile.seekg(0,ios::beg);

while(inFile.read(reinterpret_cast<char *> (&S), sizeof (Student_Management)))

if(S.getIDnum() != n)

outFile.write(reinterpret_cast<char *>(&S), sizeof


(Student_Management));

outFile.close();

inFile.close();
remove("Student_record.txt");

rename("delete.txt","Student_record.txt");

cout<<"\n\n\t Record deleted.Please press any key to continue........";

cin.ignore();// ignores the return key pressed

cin.get(); //accessing character array

// function to display the result stored

void display_result()

Student_Management S;

ifstream inFile;

inFile.open("Student_record.txt",ios::in);

if(!inFile)

cout<<"Sorry !!! File could not be open.Please press any key to continue........"
;

cin.ignore();

cin.get();

return;

cout<<"============================================================
=========================="<<endl;
cout<<"\t\t\t **REULTS OF STUDENTS** "<<endl;

cout<<"============================================================
=========================="<<endl;

cout<<"IDnum "<<"|"<<" Name "<<"|"<<" Mark in OOP " <<"|"<<" Mark in IT


"<<"|"<<" Mark in Multimedia "<<"|"

<<" Mark in Math "<<"|"<<" Percentage "<<"|"<<" Grade "<<endl;

cout<<"============================================================
=========================================="<<endl;

while(inFile.read(reinterpret_cast<char *> (&S), sizeof (Student_Management)))

S.showheader();

cin.ignore();// ignores the return key pressed

cin.get(); //accessing character array

inFile.close();

// Main function

int main()

int ch;

int n;

cout.setf(ios::fixed | ios::showpoint);

cout<<setprecision(2);
do

cout<<"=========================================================="<<
endl;

cout<<"\t ** STUDENT DATABASE MANAGEMENT SYSTEM


**"<<endl;

cout<<"=========================================================="<<
endl;

cout<<" 1. CREATE STUDENT RECORD"<<endl;

cout<<" 2. DISPLAY RECORDS OF ALL STUDENTS"<<endl;

cout<<" 3. SEARCH STUDENT RECORD"<<endl;

cout<<" 4. MODIFY STUDENT RECORD"<<endl;

cout<<" 5. DELETE STUDENT RECORD"<<endl;

cout<<" 6. DISPLAY CLASS RESULT"<<endl;

cout<<" 7. EXIT\n"<<endl;

cout<<" PLEASE ENTER YOUR CHOICE FROM (1-7) :"<<endl;

cin>>ch;

//testing the cases

switch(ch)

case 1:

student_record();
break;

case 2:

display_record();

break;

case 3:

cout<<"\n Please Enter student's ID number :"<<endl;

cin>>n;

display_search(n);

break;

case 4:

cout<<"\n Please Enter student's ID number :";

cin>>n;

modify_record(n);

break;

case 5:

cout<<"\n Please Enter student's ID number :";

cin>>n;

delete_record(n);

break;

case 6:

display_result();

break;

case 7:
exit(0);

default:

cout<<"Enter valid choice:";

while(ch != '7');

return 0;

6. Output
7.UML DIAGRAM
8. Conclusion: After the completion of this project provided by my teacher Sukant Kumar
Sahu I became familiar with the different concepts of OOP (Object oriented programming) .I
also have build up the confidence to make different program in C++ by using the concepts of
it. So, I would like to thank my teacher for giving me this project.

9. References:

1. Notes

2. Final report

You might also like