Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views6 pages

Faculty Management

This document contains a C++ program that implements a Faculty Management System using a linked list to store faculty records. It provides functionalities to insert, search, delete, and display faculty records based on employee ID. The program features a menu-driven interface for user interaction.

Uploaded by

Ishaan katara
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)
9 views6 pages

Faculty Management

This document contains a C++ program that implements a Faculty Management System using a linked list to store faculty records. It provides functionalities to insert, search, delete, and display faculty records based on employee ID. The program features a menu-driven interface for user interaction.

Uploaded by

Ishaan katara
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/ 6

#include <iostream>

#include <string.h>
#include <stdio.h>
#include<stdlib.h>
using namespace std;

//Node
class Node {
public:
int EId;
string FName;
string LName;
string Dept;
int Thours;
int Salary;
int Attendance;
string Qualification;
Node* next;

};

// Stores the head of the Linked List


Node* head = new Node();

// Check Function to check that if


// Record Already Exist or Not
bool check(int x)
{
// Base Case
if (head == NULL)
return false;

Node* t = new Node;


t = head;

// Traverse the Linked List


while (t != NULL) {
if (t->EId == x)
return true;
t = t->next;
}

return false;
}

// Function to insert the record


void Insert_Faculty_Record(int EId, string FName, string LName,
string Dept, int Thours, int Salary, int Attendance,
string Qualification)
{
// if Record Already Exist
if (check(EId)) {
cout << "Faculty with this "
<< "record Already Exists\n";
return;
}

// Create new Node to Insert Record


Node* t = new Node();
t->EId = EId;
t->FName = FName;
t->LName = LName;
t->Dept = Dept;
t->Thours = Thours;
t->Attendance = Attendance;
t->Salary = Salary;
t->Qualification = Qualification;
t->next = NULL;

// Insert at Beginning
if (head == NULL
|| (head->EId >= t->EId)) {
t->next = head;
head = t;
}

// Insert at middle or End


else {
Node* c = head;
while (c->next != NULL
&& c->next->EId < t->EId) {
c = c->next;
}
t->next = c->next;
c->next = t;
}

cout << "Record Inserted "


<< "Successfully\n";
}

// Function to search faculty using EId as Key


void Search_Faculty_Record(int EId)
{
// if head is NULL
if (!head) {
cout << "No such Faculty "
<< "Found!\n";
return;
}

// if record available
else {
Node* p = head;
while (p) {
if (p->EId == EId) {
cout << "Employee ID\t"
<< p->EId << endl;
cout << "First Name\t"
<< p->FName << endl;
cout << "Last Name\t"
<< p->LName << endl;
cout << "Department\t"
<< p->Dept << endl;
cout << "Teaching Hours\t"
<< p->Thours << endl;
cout << "Salary\t\t"
<< p->Salary << endl;
cout << "Attendance\t"
<< p->Attendance << endl;
cout << "Qualification\t"
<< p->Qualification << endl;
return;
}
p = p->next;
}

if (p == NULL)
cout << "No such Record "
<< "Available\n";
}
}

// Function to delete record students


// record with given EId number
// if it exist
int Delete_Faculty_Record(int EId)
{
Node* t = head;
Node* p = NULL;

// Deletion at Begining
if (t != NULL
&& t->EId == EId) {
head = t->next;
delete t;

cout << "Faculty Deleted "


<< "Successfully\n";
return 0;
}

// Deletion Other than Begin


while (t != NULL && t->EId != EId) {
p = t;
t = t->next;
}
if (t == NULL) {
cout << "Faculty does not Exist\n";
return -1;
p->next = t->next;

delete t;
cout << "Faculty Deleted "
<< "Successfully\n";

return 0;
}
}

// Function to display the Student's


// Record
void Show_Faculty_Record()
{
Node* p = head;
if (p == NULL) {
cout << "No Record "
<< "Available\n";
}
else {
cout << "Employee ID\tFirst Name\tLast Name\tDepartment"
<< "\tTeaching Hours\tSalary\tAttendance\tQualification\n";

// Until p is not NULL


while (p != NULL) {
cout << p->EId << "\t\t"
<< p->FName << "\t\t"
<< p->LName << "\t\t"
<< p->Dept << " \t\t"
<< p->Thours << " \t\t"
<< p->Salary << " \t"
<< p->Attendance << " \t\t"
<< p->Qualification << " \t\t" << endl;
p = p->next;
}
}
}

// Driver code
int main()
{
head = NULL;
string FName, LName, Dept, Qualification;
int EId, Thours, Salary, Attendance;
char ch;

// Menu-driven program
do {
cout << "\n\t\tFaculty Management System "
"\n\n\tPress\n\t1 to "
"create a new Record\n\t2 to delete a "
"Faculty Record\n\t3 to Search a Faculty "
"Record\n\t4 to view all Faculties "
"\n\t5 to Exit\n";
cout << "\nEnter your Choice\n";
int Choice;

// Enter Choice
cin >> Choice;
if (Choice == 1) {
cout << "Enter Employee ID of faculty\n";
cin >> EId;
cout << "Enter First Name of Faculty\n";
cin>>FName;
cout << "Enter Last Name of Faculty\n";
cin >> LName;
cout << "Enter Faculty Department \n";
cin >> Dept;
cout << "Enter Teaching Hours of Faculty\n";
cin >> Thours;
cout << "Enter Faculty's Salary\n";
cin >> Salary;
cout << "Enter Faculty's Attendance\n";
cin >> Attendance;
cout << "Enter Faculty's Qualification\n";
cin >> Qualification;
Insert_Faculty_Record(EId, FName, LName, Dept, Thours,
Salary, Attendance, Qualification);
}
else if (Choice == 2) {
cout << "Enter Empoyee ID of Faculty whose "
"record is to be deleted\n";
cin >> EId;
Delete_Faculty_Record(EId);
}
else if (Choice == 3) {
cout << "Enter Employee ID of whose "
"record you want to Search\n";
cin >> EId;
Search_Faculty_Record(EId);
}
else if (Choice == 4) {
Show_Faculty_Record();
}
else if (Choice == 5) {
exit(0);
}
else {
cout << "Invalid Choice "
<< "Try Again\n";
}
cout<<endl<<"Press 'Y' to continue..";
cin>>ch;
}while(ch=='y' || ch=='Y');
return 0;
}

You might also like