Professional Documents
Culture Documents
Section # S1
PROJECT:
#include <iostream>
#include <string>
#include <fstream>
struct node
int section;
};
class list
{
node *head,*last;
public:
list()
head=NULL;
last=NULL;
temp->first_name=_first_name;
temp->last_name=_last_name;
temp->course=_course;
temp->reg=_reg;
temp->department=_department;
temp->section=_section;
temp->fees=_fees;
temp->message=_message;
temp->next=NULL;
temp->previous=NULL;
if(head==NULL)
{
head=temp;
last=temp;
else
last->next=temp;
temp->previous=last;
last=last->next;
void display()
node *temp=head;
if(head==NULL)
cout<<"\n\t\tList is Empty\n"<<endl;
else
while(temp!=NULL)
cout<<"|"<<temp->first_name<<"|\n";
cout<<"|"<<temp->last_name<<"|\n";
cout<<"|"<<temp->course<<"|\n";
cout<<"|"<<temp->reg<<"|\n";
cout<<"|"<<temp->department<<"|\n";
cout<<"|"<<temp->section<<"|\n";
cout<<"|"<<temp->fees<<"|\n";
cout<<"|"<<temp->message<<"|\n";
temp=temp->next;
void delete_student()
node *current=search_position();
if(current==NULL)
if(head==NULL)
cout<<"List is Empty"<<endl;
else
{
cout<<"Student not Found"<<endl;
delete current;
head=NULL;
last=NULL;
else if(current==head)
head=head->next;
head->previous=NULL;
delete current;
else if(current==last)
last=last->previous;
last->next=NULL;
delete current;
else
current->previous->next=current->next;
current->next->previous=current->previous;
delete current;
cout<<"\nSTUDENT deleted\n"<<endl;
node* search_position()
string student_to_delete;
cin>> student_to_delete;
node *temp=head;
while(temp!=NULL)
if(temp->reg == student_to_delete)
return temp;
else
temp=temp->next;
}
return temp;
void editing()
node *current=search_position();
if(current==NULL)
if(head==NULL)
cout<<"List is Empty"<<endl;
else
char choice;
do
system("cls");
cout<<"\t\t\tCHOICES\n"<<endl;
cout<<"\t\t\t--> E tp EXIT"<<endl;
char editing_choice;
cin>>editing_choice;
system("cls");
switch(editing_choice)
case 'F':
string new_name;
cin>>new_name;
current->first_name=new_name;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
case 'L':
{
string l_name;
cin>>l_name;
current->last_name=l_name;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
case 'C':
string new_courses;
cin>>new_courses;
current->course=new_courses;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
case 'R':
string new_Reg;
cin>>new_Reg;
current->reg=new_Reg;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
}
case 'D':
string new_department;
cin>>new_department;
current->department=new_department;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
case 'S':
int new_sec;
cin>>new_sec;
current->section=new_sec;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
case 'X':
string new_fee;
cin>>new_fee;
current->fees=new_fee;
cout<<"\nSuccessfully Changed\n"<<endl;
break;
case 'E':
break;
cin>>choice;
}while((choice=='y'||choice=='Y'));
void search()
string student_to_search;
cin>> student_to_search;
node *temp=head;
while(temp!=NULL)
if(temp->reg == student_to_search)
{
break;
else
temp=temp->next;
void save()
ofstream file("D:\\student_management_system.txt");
node* temp=head;
node* temp2=NULL;
while(temp!=NULL)
file<<temp->first_name <<"\n";
file<<temp->last_name <<"\n";
file<<temp->course <<"\n";
file<<temp->reg <<"\n";
file<<temp->department <<"\n";
file<<temp->section <<"\n";
file<<temp->fees <<"\n";
file<<temp->message <<"\n";
temp2=temp;
temp=temp->next;
delete temp2;
file.close();
void load()
ifstream file("D:\\student_management_system.txt");
if(!file)
cout<<"\nEmpty\n"<<endl;
else
while(!file.eof())
string fn;
file>>fn;
string ln;
file>>ln;
string cr;
file>>cr;
string rg;
file>>rg;
string dp;
file>>dp;
int sec;
file>>sec;
string f;
file>>f;
string msg;
file>>msg;
create_node(fn,ln,cr,rg,dp,sec,f,msg);
node*current=head;
node*pcurrent=current;
while(current->next!=NULL)
pcurrent=current;
current=current->next;
last=pcurrent;
pcurrent->next=NULL;
delete current;
};
int main()
list obj;
obj.load();
int choice;
char selection;
do
system("cls");
cout<<"\t\t\t******************************"<<endl<<endl;
cout<<"\t\t\t******************************"<<endl<<endl;
cin>>choice;
system("cls");
switch(choice)
case 1:
string fname,lname,course,reg,department,fees;
int section ;
cin>>fname ;
cin>>lname ;
cin>>course ;
cin>>reg ;
cout<<"Enter Department"<<endl;
cin>>department ;
cout<<"Enter Section"<<endl;
cin>>section ;
cout<<"Enter Fees"<<endl;
cin>>fees ;
system("cls");
obj.create_node(fname,lname,course,reg,department,section,fees);
obj.display();
break;
case 2:
obj.delete_student();
obj.display();
break;
case 3:
obj.search();
break;
case 4:
obj.editing();
cout<<endl;
obj.display();
break;
case 5:
obj.display();
break;
}
cin>>selection;
}while((selection=='y')||(selection=='Y'));
obj.save();