0% found this document useful (0 votes)
48 views

OOP (Lab) Project #1 Report

This document describes a C++ student database management system project that allows a university administration to store and manage student records. The system uses classes, constructors, destructors, and file handling to add, display, and delete student records from a data file. Key features include adding a student record by inputting their details, displaying all student records by reading from the data file, and deleting a record by admission number. The project aims to help manage the student records in a university administration through a console application built in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

OOP (Lab) Project #1 Report

This document describes a C++ student database management system project that allows a university administration to store and manage student records. The system uses classes, constructors, destructors, and file handling to add, display, and delete student records from a data file. Key features include adding a student record by inputting their details, displaying all student records by reading from the data file, and deleting a record by admission number. The project aims to help manage the student records in a university administration through a console application built in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Students Database Management System

Name:
Reg no:
Teacher:

The System designed to keep track of the information of the Students.

Introduction
This software will be developed for the University administration to keep record of students. Student
Database Management System will be implemented using C++ Class Constructors and Destructors.
Constructor is a method for a class that gets called automatically whenever an object of the class is
created. It is used to give the class’s data initial values.
Destructor is a method for a class that gets called automatically whenever an object of the class is
deleted. It is used to delete any memory that the class has dynamically allocated.
Default Constructor is a constructor that takes no parameters, and gives the class’s data default
initial values. It is always called for each array element when an array of the class’s objects is
created.
Copy Constructor is a constructor that takes another object of the same class as its reference
parameter, and makes the new object an exact copy of the argument

Software and hardware requirements for this project


1. Dev C++
2. PC system

Project description
Student Database Management System is a C++ console application that helps the university
administration to keep record of students. This application will use file handling for managing
student data. Application will include following features
1. Add Student Record
2. Delete Student Record
3. Display Students
Students Database Management System

Add Student Record


This feature will allow admin to add student information records. That includes the student’s name,
course and section. All the added records in this student database management system are stored in
file.
Delete Student Record
This feature is for deleting the added students’ information from the file.
Display Students
It will display all the information of students.

Code:
#include<iostream>
#include<fstream> //Header files
#include<stdlib.h>
#include<string.h>
#include<conio.h>

using namespace std;

class Student
{
private:
int admNo;
//Addmission no
char name[20]; // Array
of names
char gender; // Gender of
each student
char course[20]; // Course of
students
char address[100]; // Address of
students
char phoneNo[15]; // Cell no of
students

public:
Student() //Default
Constructor
{ }
Student(Student &st) //Copy
Constructor
{
admNo = st.admNo;
strcpy(name, st.name); //The strcpy() function in C++ copies a character
string from source to destination.
gender = st.gender;
strcpy(course, st.course);
strcpy(address, st.address);
strcpy(phoneNo, st.phoneNo);
Students Database Management System

}
void getStdData();
void showStdData();
int getAdmNo() // Getter
for addmission no.
{
return admNo;
}
~Student() //
destructor
{ }
};
inline void Student::getStdData() // fucntion member
decleared outside the class
{
cout << "\n\nEnter Student Details......\n";
cout << "Enter Admission No. : ";
cin >> admNo;
cout << "Enter Full Name : ";
cin.ignore();
cin.getline(name, 20);
cout << "Enter Gender (M/F) : ";
cin >> gender;
cout << "Enter Course : ";
cin.ignore();
cin.getline(course, 20);
cout << "Enter Address : ";
cin.getline(address, 100);
cout << "Enter Phone No. : ";
cin.getline(phoneNo, 15);
cout << endl;
}
inline void Student::showStdData()
{

cout << "\n\n.......Student Details......\n";


cout << "Admission No. : " << admNo << endl;
cout << "Full Name : " << name << endl;
cout << "Gender : " << gender << endl;
cout << "Course : " << course << endl;
cout << "Address : " << address << endl;
cout << "Phone No. : " << phoneNo << endl;
cout << endl;
}
Student std1;
//defalut constructor invoked
Student std2 = std1;
//copy constructor invoked
Students Database Management System

void addStdData()
{
ofstream fout;
fout.open("Students.dat", ios::binary | ios::out | ios::app); // fout used instead
of cout
std1.getStdData();
fout.write((char * ) &std1, sizeof(std1));
fout.close();
cout << "\n\nData Successfully Saved to File....\n";
}

void displayStdData()
{
ifstream fin;
// fin used insted of cin
fin.open("Students.dat", ios:: in | ios::binary);
while (fin.read((char * ) &std1, sizeof(std1)))
{
std1.showStdData();
}
fin.close();
cout << "\n\nData Reading from File Successfully Done....\n";
}

void deleteStdData()
{
int addno;
bool isfound = false;
ifstream fin;
ofstream tempFile;

fin.open("Students.dat", ios:: in | ios::binary);


tempFile.open("TempFile.dat", ios::out | ios::app | ios::binary);

cout << "Enter Admission Number you want to delete: ";


cin >> addno;

while (fin.read((char * ) & std1, sizeof(std1)))


{
if (addno == std1.getAdmNo())
{
cout << "The Following Admission No. " << addno << " has been deleted.\n";
std1.showStdData();
isfound=true;
} else
{
tempFile.write((char * ) & std1, sizeof(std1));
}
}
tempFile.close();
fin.close();
Students Database Management System

if (isfound == false)
{
cout << "The Admission No. " << addno << " not found....\n\n";
}
remove("Students.dat");
rename("TempFile.dat", "Students.dat");
}
// Main Function Decleration
int main()
{
cout<<"\n";
cout<<"\n";
cout<<"\t\t\t\t\t*****************************************************"<<endl;
cout<<"\t\t\t\t\t Student Management System "<<endl;
cout<<"\t\t\t\t\t*****************************************************"<<endl;
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\t\t\t\t\tUniversity:"<<endl;
cout<<"\t\t\t\t\t___________"<<endl;
cout<<"\n";
cout<<"\t\t\t\t\t University"<<endl;
cout<<"\n";
cout<<"\t\t\t\t\tSubmitted to:"<<endl;
cout<<"\t\t\t\t\t_____________"<<endl;
cout<<"\n";
cout<<"\t\t\t\t\tSir "<<endl;
cout<<"\n";
cout<<"\t\t\t\t\tProject Made by:"<<endl;
cout<<"\t\t\t\t\t________________"<<endl;
cout<<"\n";
cout<<"\t\t\t\t\t1."<<endl;
cout<<"\t\t\t\t\tReg no. "<<endl;
cout<<"\t\t\t\t\tBS(CS) 2 "<<endl;
cout<<"\t\t\t\t\t2. "<<endl;
cout<<"\t\t\t\t\tReg no."<<endl;
cout<<"\t\t\t\t\tBS(CS) 2"<<endl;

cout<<"\n";
cout<<"To Continoue .... press any key..."<<endl;
getch();
system ("cls");
int ch;
do {
char choice_1;
cout << "0. Exit from Program\n";
cout << "1. Add Student Record\n";
cout << "2. Display Students\n";
cout << "3. Delete Student\n";
cout << "Enter your choice : ";
cin >> ch;
Students Database Management System

system("cls");
switch (ch) {
case 1:
addStdData();
break;
case 2:
displayStdData();
break;
case 3:
deleteStdData();
break;
}
// system("pause");
} while (ch);
return 0;
}

You might also like