0% found this document useful (0 votes)
28 views15 pages

Student Data Management System

The student data management system is a C++ application that uses classes and linked lists to organize and manipulate student information. It features a menu-driven interface to perform tasks like inserting, searching, deleting, and analyzing student data for individual students or entire classes. The system demonstrates an effective approach to handling student records in a user-friendly manner.
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)
28 views15 pages

Student Data Management System

The student data management system is a C++ application that uses classes and linked lists to organize and manipulate student information. It features a menu-driven interface to perform tasks like inserting, searching, deleting, and analyzing student data for individual students or entire classes. The system demonstrates an effective approach to handling student records in a user-friendly manner.
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/ 15

Student Data Management Syste

SUBMITTED TO:
SUBMITTED BY:
STUDENT DATA MANAGEMENT SYSTEM
Introduction:

The Student Data Management System is a C++ console application designed to facilitate the
organization and manipulation of student information. The project is structured around classes
such as Student, Node, and StudentList, utilizing linked lists for efficient data management.
The system features a menu-driven interface to perform tasks like inserting, searching, deleting,
and analyzing student data.

Classes and Data Structures:


1. Student Class:
Attributes:
 rollNo: Integer representing the student's roll number.
 name: String containing the student's name.
 department: String indicating the student's department.
 subjects: Array of strings representing the student's subjects.
 marks: Array of floats storing the student's marks in each subject.
 grade: Character representing the student's grade.
Methods:
 Student: Constructor for initializing student data.

2.Node Class:
Attributes:
 data: Student object containing student information.
 next: Pointer to the next node in the linked list.
Methods:
 Node: Constructor for initializing a node with student data.

3.StudentList Class:
Attributes:
 head: Pointer to the first node in the linked list.
Methods:
 displayMenu: Displays the menu of available operations.
 insertStudent: Inserts a new student into the linked list.
 searchAndInsert: Searches for a specific roll number and inserts new data
after it.
 deleteStudent: Deletes a student with a specified roll number.
 calculateMarksAndGrade: Calculates marks and assigns a grade for a
specific roll number.
 calculateClassStats: Calculates statistics for the entire class.
 displayStudentTable: Displays a table of student information.
 clearScreen: Clears the console screen.

4.Main Function (_tmain):


Implements the user interface and handles user input to perform operations on the StudentList.

Features:
1.Insert Student Data:
Allows the user to input student details and inserts the student into the list.
2.Search and Insert Data:
Searches for a specified roll number and inserts new data after it.
3.Delete Student Data:
Deletes a student with a specified roll number from the list.
4.Calculate Marks and Grade:
Calculates the total marks and assigns a grade for a specified roll number.
5.Calculate Class Stats:
Calculates statistics for the entire class, including total students, class percentage, and the
number of students passed or failed.
6.Display Student Table:
Displays a tabular representation of student information, including roll number, name,
percentage, and grade.
7.User-Friendly Interface:
Presents a menu-driven interface for users to interact with the system easily.

Conclusion:
The Student Data Management System demonstrates an effective approach to handling student
information in a user-friendly manner. Leveraging linked lists and a menu-driven interface, the
program provides a versatile and accessible platform for managing academic records. While
ensuring data accuracy and preventing duplicates, the system caters to the diverse needs of users
involved in student data management.

Code:
// project.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class Student {
public:
int rollNo;
string name;
string department;
string subjects[4]; // Array for 4 subjects
float marks[4]; // Assuming 4 subjects
char grade;

Student(int roll, const string& n, const string& dept, const string& sub1, const string& sub2,
const string& sub3, const string& sub4)
: rollNo(roll), name(n), department(dept), grade(' ') {
subjects[0] = sub1;
subjects[1] = sub2;
subjects[2] = sub3;
subjects[3] = sub4;

for (int i = 0; i < 4; ++i) {


marks[i] = 0;
}
}
};

class Node {
public:
Student data;
Node* next;

Node(const Student& s) : data(s), next(nullptr) {}


};

class StudentList {
private:
Node* head;

public:
StudentList() : head(nullptr) {}

void displayMenu() {

cout<<" **STUDENT DATA MANAGEMENT


SYSTEM**"<<endl;
cout<<endl;
cout << " 1. Insert Student Data\n";
cout << " 2. Search and Insert Data\n";
cout << " 3. Delete Student Data\n";
cout << " 4. Calculate Marks and Grade\n";
cout << " 5. Calculate Class Stats\n";
cout << " 6. students data\n";
cout << " 7. Exit\n";
cout<<endl;
cout << "Enter your choice: ";

}
void insertStudent(const Student& newStudent) {
Node* newNode = new Node(newStudent);

if (!head || head->data.rollNo > newStudent.rollNo) {


newNode->next = head;
head = newNode;
cout << "Student inserted.\n";
return;
}

Node* current = head;


while (current->next && current->next->data.rollNo < newStudent.rollNo) {
current = current->next;
}

newNode->next = current->next;
current->next = newNode;

cout << "Student inserted.\n";


}

void searchAndInsert(int searchRollNo, const Student& newStudent) {


Node* current = head;
Node* prev = nullptr;

// Find the node with the given searchRollNo or the position to insert
while (current && current->data.rollNo < searchRollNo) {
prev = current;
current = current->next;
}

if (current && current->data.rollNo == searchRollNo) {


// Roll number found, now check if new Roll No already exists
if (current->next && current->next->data.rollNo == newStudent.rollNo) {
// New Roll No already exists, display message and return
cout << "Roll No " << newStudent.rollNo << " already exists. Data not inserted.\n";
} else {
// New Roll No not found, insert new data
Node* newNode = new Node(newStudent);
newNode->next = current->next;
current->next = newNode;
cout << "Data inserted after Roll No " << searchRollNo << ".\n";
}
} else {
// Roll number not found, display error message
cout << "Roll No " << searchRollNo << " not found. Data not inserted.\n";
}
}

void deleteStudent(int rollNo) {


if (!head) {
cout << "List is empty. Nothing to delete.\n";
cout<<endl;
return;
}

if (head->data.rollNo == rollNo) {
Node* temp = head;
head = head->next;
delete temp;
cout << "Student with Roll No " << rollNo << " deleted.\n";
cout<<endl;
return;
}

Node* current = head;


while (current->next && current->next->data.rollNo != rollNo) {
current = current->next;
}

if (current->next) {
Node* temp = current->next;
current->next = current->next->next;
delete temp;
cout<<endl;
cout << "Student with Roll No " << rollNo << " deleted.\n";
cout<<endl;
} else {
cout<<endl;
cout << "Student with Roll No " << rollNo << " not found. Nothing deleted.\n";
cout<<endl;
}
}

// Inside the calculateMarksAndGrade function


void calculateMarksAndGrade(int rollNo) {
Node* current = head;
while (current && current->data.rollNo != rollNo) {
current = current->next;
}

if (current) {
// Perform calculations and display student data
int totalMarks = 0; // Initialize total marks

// Take input for marks for each subject


for (int i = 0; i < 4; ++i) {
do {
cout << " Enter marks for " << current->data.subjects[i] << ": ";
cin >> current->data.marks[i];

// Validate that marks are not more than 50


if (current->data.marks[i] > 50) {
cout << "Invalid input! Marks should not exceed 50. Please enter again.\n";
}
}

while (current->data.marks[i] > 50);

totalMarks += current->data.marks[i];
}

// Assign grade based on total marks


if (totalMarks >= 90) {
current->data.grade = 'A';
} else if (totalMarks >= 80) {
current->data.grade = 'B';
} else if (totalMarks >= 70) {
current->data.grade = 'C';
}
else if (totalMarks >= 60) {
current->data.grade = 'D';}
else {
current->data.grade = 'F';
}

cout << " -- Student Data --"<<endl;


cout<<endl;
cout << "Roll No: " << current->data.rollNo << "\n";
cout << "Name: " << current->data.name << "\n";
cout << "Department: " << current->data.department << "\n";
cout<<endl;
cout << " -- Subjects -- "<<endl;
for (int i = 0; i < 4; ++i) {
cout << current->data.subjects[i] << " ";
}
cout << "\n";
cout << "Total Marks: " << totalMarks << "\n";
cout << "Grade: " << current->data.grade << "\n";
} else {
cout << "Student with Roll No " << rollNo << " not found.\n";
}
}

void calculateClassStats() {
if (!head) {
cout << "Class is empty. No statistics to calculate.\n";
return;
}

int totalStudents = 0;
int passCount = 0;
int failCount = 0;

Node* current = head;


while (current) {
totalStudents++;

// Check if the student passed based on the grade


if (current->data.grade == 'A' || current->data.grade == 'B' || current->data.grade == 'C' ||
current->data.grade == 'D') {
passCount++;
} else {
failCount++;
}

current = current->next;
}

// Calculate class percentage


float classPercentage = (static_cast<float>(passCount) / totalStudents) * 100;

cout << "Class Statistics:\n";


cout << "Total Students: " << totalStudents << "\n";
cout << "Class Percentage: " << classPercentage << "%\n";
cout << "Number of Students Passed: " << passCount << "\n";
cout << "Number of Students Failed: " << failCount << "\n";
}

void displayStudentTable() {
if (!head) {
cout << "Class is empty. No students to display.\n";
return;
}

cout << "+------------+----------------------+---------------+--------+\n";


cout << "| Roll No | Name | Percentage | Grade |\n";
cout << "+------------+----------------------+---------------+--------+\n";

Node* current = head;


while (current) {
float totalMarks = 0;
for (int i = 0; i < 4; ++i) {
totalMarks += current->data.marks[i];
}

float percentage = (totalMarks / 200) * 100; // Assuming total marks for 4 subjects is 200

cout << "| " << setw(10) << current->data.rollNo << " | " << setw(20) << current-
>data.name
<< " | " << fixed << setprecision(2) << setw(13) << percentage << " | " << setw(6) <<
current->data.grade << " |\n";

current = current->next;
}
cout << "+------------+----------------------+---------------+--------+\n";
}
};
void clearScreen() {
system("cls");
}
int _tmain(int argc, _TCHAR* argv[]) {
StudentList studentList;
while (true) {
studentList.displayMenu();
int choice;
cin >> choice;
switch (choice) {
case 1: {
clearScreen();
int rollNo;
string name, department, subjects[4];
cout << "Enter Roll No: ";
cin >> rollNo;
cout << "Enter Name: ";
cin.ignore();
getline(cin, name);
cout << "Enter Department: ";
getline(cin, department);
cout << "-- Enter Subjects --\n";
for (int i = 0; i < 4; ++i) {
cout << "Enter subject " << (i + 1) << ": ";
cin >> subjects[i];
}
Student newStudent(rollNo, name, department, subjects[0], subjects[1], subjects[2],
subjects[3]);
studentList.insertStudent(newStudent);
break;
}
case 2: {
clearScreen();
int searchRollNo;
cout << "Enter Roll No after which you want to add data: ";
cin >> searchRollNo;

int rollNo;
string name, department, subjects[4];

cout << "Enter Roll No: ";


cin >> rollNo;
cout << "Enter Name: ";
cin.ignore();
getline(cin, name);
cout << "Enter Department: ";
getline(cin, department);
cout<<endl;
cout << " -- Enter Subjects -- "<<endl;
for (int i = 0; i < 4; ++i) {
cout << "Enter subject " << (i + 1) << ": ";
cin >> subjects[i];
}

Student newStudent(rollNo, name, department, subjects[0], subjects[1], subjects[2],


subjects[3]);
studentList.searchAndInsert(searchRollNo, newStudent);
break;
}
case 3: {
clearScreen();
int rollNoToDelete;
cout << "Enter Roll No to delete: ";
cin >> rollNoToDelete;

studentList.deleteStudent(rollNoToDelete);
break;
}
case 4: {
clearScreen();
int rollNoToCalculate;
cout << "Enter Roll No to calculate marks and grade: ";
cin >> rollNoToCalculate;
cout<<endl;
studentList.calculateMarksAndGrade(rollNoToCalculate);
break;
}
case 5:
clearScreen();
studentList.calculateClassStats();
break;
case 6:
clearScreen();
studentList.displayStudentTable();
break;
case 7:
clearScreen();
cout << "Exiting program. Goodbye!\n";
return 0;
default:
clearScreen();
cout << "Invalid choice. Please try again.\n";
}
}
system("pause");
return 0;
}

Output:
Inserting Choice 1:
Entering choice 2:
Entering choice 3:

Entering Choice 4:
Entering Choice 5:

Entering Choice 6:

You might also like