student management system project in cpp


Student management system




1. INTRODUCTION:

Our project is a  student management system project. It includes all details about a syudent studying in college such as his/her admission info,admission type,courses he/she have enrolled in,etc.

2. AIM :

To provide a  platform for handling students data and their academic progress.

 

3. MODULES OF THE PROJECT :

1)Student  information (Name,address,mobile number,email:int/char type)

2)  Csv(excel)file for storing students data

3)Enrollment number/Prn_no:string type

4)Name:string type

5)roll_no :int type

 

4.EXPLANATION :

Basic functioning of the system is registering the students, storing record of currently studying students ,deleting or  arranging records of previously passout students.This system only allows faculties to authorize this data .This project helps to create database of students studying in any organization or institute so it will no more tideous task to college /university faculties to maintain students information in various files or creating separate  files to each of them.All students personal info and attendance data is stored in files so that it will be convenient to access them efficiently.

5.Algorithm/pseudo code –

A) For main function():

1)start.

Declare and define functions according to program. )Enter tasks to perform using switch case in main() function. eg.create().modify(),delete(),etc.

2)For login and register using switch case for giving choices.

1>login 2>Register

 

         i)For login function:

        cout << "Enter your username\n";

              cin >> username;

             cout << "Enter your password\n";    cin >> password;

              ifstream input("data.txt", ios::app);          //storing login details in data.txt file

             while (input.peek() != EOF)    {

              getline(input >> ws, usr, ',');

getline(input >> ws, pwd, '\n');

             if (username.compare(usr) == 0) {                //checking condition as entered username                  or password is correct or not

            if (password.compare(pwd) == 0)    {state = 1;

                cout << "login successfull!! \n"

                     << "welcome back " << usernam   }   }

 

       ii)For register function:

Enter username and password for first time registration and store that credentials into “data.txt “ file as shown in step 1)

 iii) For password reset function:

Input:  string password, name,new ,key, freset;

cout<<"Enter Username :";  getline(cin>>ws,input);

transform(input.begin(), input.end(), input.begin(), ::tolower); //converting into lowercase

cout<<"Enter New Password :";  getline(cin>>ws,neww);

cout<<"Enter Pass reset key :";  getline(cin>>ws,key);

transform(uname.begin(), uname.end(), uname.begin(), ::tolower); //converting into lowercase

fin.open("pass.txt");                //opening saved  information  of registration credentials file

while(fin.peek()!=EOF){getline(fin,name,',');

getline(fin,password,',');

getline(fin,freset,'\n');

if(name.compare(input)==0){n=i;                       //Comparing our entered credentials with      

                                                                                   saved credentials

s1=name;  s2=password;}                                    

if(key.compare(freset)==0){jj=00;}           

           f(jj==00){   cout<<"\tPassword rest succesfull\n";

//If a variable named j==0 then some error get occur in resetting  password and that reset information get deleted using delete_line function.

            delete_line("pass.txt", n);

            ofstream fout;

            fout.open("pass.txt",ios::app);

            fout<<s1<<","<<neww<<","<<key<<"\n";

            fout.close();}

            if(j==1){   cout<<"Wrong passkey\n unable to reset\n";

 //Checking password requirements in resetting password else we are unable to reset password

//End of password reset function.

 

 

 

 

3)Input student information and store it using function create();//for creating student record.

Input:Name, Roll_no , prn _no.

Store all data into csv file which is a database for storing student’s data.//using ofstream file format for writing data.

4)Search student record by invoking  search() function call.//using  ifstream file format for reading student data.

i)using switch case inside search() function definition for giving choice as

 search data by  roll_no   or search by name.

5) For modifying  or update student record  invoke replacecall() function which is  defined in another cpp file named “modifycode.cpp” whose haeder file is included in main program.

Control of program will transfer to modifycode cpp file after we call it from main function.

 

B)For modify code/update info of student/for deleting info:

     a) for modifying student info:

1)Function call “replacecall()”which is  under modify() function  from main function get executes in modifycode.cpp file.

2)In repalcecall() function:

Input: Roll_no to modify

3)Read whole file using ifstream format of file reading and compare our entered data with existing data in the file using “if” condition.

4)If compare result ==0,then display student data from records created.

5) After modifying data, encounter delete _line() function for deleting line space created by pre-existing data .//because we are using csv(excel) file for storing student data.

 

    b)for deleting student info :

1) Function call “deletecall()”which is  under modify() function  from main function get executes in modifycode.cpp file.

2)In deletecall() function:

Input:Roll_no to delete info.

3)Read file info using ifstream format of file reading reading and compare our entered data with existing data in the file using “if” condition.

 4)If compare result ==0,then invoke delete_linee() function to delete student data from records created.

5)In delete_linee() function:

//create a temporary file to store current data from original file

 

     i)Create a temp.txt file in outstream mode and add all created records into and the the      record which we want to delete will remain in original file.

     ii) Remove original file and rename temp.txt file as original file .Record of student will get deleted.

 

C) For student attendance info:

A)In attendance() function of main code two functions are in it as follows:

i>markattendance() ;         //function definition is in Markattendance file

ii>readattendance();          //function definition is in Readattendance file

 /*Attendance functions to write & read the student attendance.

Storing  attendance  code in separate file named Markattendance for writing attendance and other file Readattendance for reading attendance*/

     **There are two functions in markattendance file :

A)For markattendance () function:

1)Int writeattendance():

//declare int,float,char and string variables to access data.

Input : Roll_no,date,month,year

Write date in “Newattend.csv” file we created and close the file.

//storing sub as per choice in sub variable and calling attendance() function(step ii) to input attendance as present or absent.

For eg.

Sub=”at”         //sub name is a string

attendance();                //go to step ii)

 

2)For void attendance():

1)for present :

/*After calling attendance() function from writeattendance() function,program control passed to attendance() function to input attendance as present ,bsent,lecture not scheduled*/

Using switch case in attendance() function for 1)present 2)absent 3)lecture not scheduled

 

1)If present --->increment print variable and lecture/period by 1 and fout<<”sub:” “<<”p”<<”,”;

2)for absent:

If absent--->increment lecture/period no by 1 and fout<<”sub:” “<<”NA”<<”,”;

//calculate attendance using

attendance1 = present/periods;

attendance1 = attendance1*100;

cout<<"Attendance is :"<<attendance1<<"%\n";

//store info in ofstream fiut("Newattend.csv",ios::app); and close file

 

B)For Readattendance() function:

Using switch case input functions as:

Input int variable for accessing  switch case.

cout<<"1.search by roll and date\n2.search by date only\n3.search all data by roll no.\n4.View attendance of Sub\n";

   i>for case 1:

cout<<"Enter roll no: ";

cin>>Nroll;

cout<<"Enter date in dd-mm-yyyy format\n";

getline(cin>>ws,Ndate);

readbyrolldate();             // program control goes to function             

                                                              defination     

     ii>for case 2:

        cout<<"Enter date in dd-mm-yyyy format\n";

          getline(cin>>ws,Ndate);

          readbydate();}                               //program control goes to function definition

    iii>for case 3:

        cout<<"Enter date in dd-mm-yyyy format\n";

       getline(cin>>ws,Ndate);

       readbydate();}             //program control goes to function definition

      //calculating total attendance:

      totalattendence = totalattendence/counttheaverage;

       cout<<"And Total Attendance is:    "<<setprecision(4)<<totalattendence<<"%"<<endl;}

 

    iv>For case 4:

    cout<<"1.SE\t2.CO\t3.OOP\t4.AT\n5.OS\t6.CN2\n";

   int schoice;   cin>>schoice;

   switch(schoice) {

   case 1: Psub ="SE :P"; Asub ="SE :A"; attendbysub();  //program control goes to function definition

break;

    case 2: Psub ="CO :P"; Asub ="CO :A"; attendbysub(); break;

    case 3: Psub ="oop :P"; Asub ="oop :A"; attendbysub(); break;

    case 4: Psub ="AT :P"; Asub ="AT :A"; attendbysub();break;

    case 5: Psub ="OS :P"; Asub ="OS :A";attendbysub();  break;

    case 6: Psub ="CN2:P"; Asub ="CN2:A";  attendbysub();break; }

 

1)function definition of void readbyrolldate():

ifstream disp("Newattend.csv");         //read from our created file and read it till end using disp.peek() condition

while(disp.peek()!=EOF){

getline(disp>>ws,Droll,',');            //input roll no and date we want to search for

getline(disp>>ws,Ddate,',');

//Comparing date and roll_no using compare format of c++

if(Nroll.compare(Droll)==0){

if(Ndate.compare(Ddate)==0){

cout<<"Date : "<<Ddate<<endl;

cout<<"sub  P/A\n"<<endl;

cout<<fse<<endl<<fco<<endl<<foop<<endl<<fos<<endl<<fcn<<endl;

cout<<"Attendance : "<<Dattend<<"%"<<endl<<endl;}}

//Dispalying info of student if both nested conditions get true

2)function definition of readbydate():

//Reading file same as in function 1)

Repeat same steps as function 1) for searchbydate()  but here only for date.

getline(dispday>>ws,Ddate,',');

if(Ndate.compare(Ddate)==0){/

repeat  steps inside if function in  function  1)}

3)Function definition of  void readalldata():

Repeat steps of 1) function for displaying all data.

Input:roll_no

Repeat steps of function 1)

 

4)Function definition for attendancebysub():

Input:Roll_no,astate=0, precounter=0,

  abcounter = 0;

Open file ifstream absub("Newattend.csv");

while(absub.peek()!=EOF){

if(Nroll.compare(Droll)==0){

   atstate = 1;

if(Psub.compare(fse)==0){precounter = precounter +1;}         

   //checking conditions for attendance by sub and likewise increasing counter variable for counting attendance

        if(Asub.compare(fse)==0){abcounter = abcounter +1;}

        if(Psub.compare(fco)==0){precounter = precounter +1;}

        if(Asub.compare(fco)==0){abcounter = abcounter +1;

        if(Psub.compare(foop)==0){precounter = precounter +1;}

        if(Asub.compare(foop)==0){abcounter = abcounter +1;}

        if(Psub.compare(fat)==0){precounter = precounter +1;}

        if(Asub.compare(fat)==0){abcounter = abcounter +1;}

        if(Psub.compare(fos)==0){precounter = precounter +1;}

        if(Asub.compare(fos)==0){abcounter = abcounter +1;}

        if(Psub.compare(fcn)==0){precounter = precounter +1;}

        if(Asub.compare(fcn)==0){abcounter = abcounter +1;  }}

        if(atstate == 0){cout<<"Sory No data Found\n";}

        if(atstate == 1){

    cout<<"total present was "<<precounter<<endl;        //printing present and absent count

    cout<<"total absent was "<<abcounter<<endl;

//End of Readattendance function

D)For student_academicrecord ()function:

1)void academicrecord():

Using switch case to enter choice as 1)addrecord 2)viewrecord

a)void addrecord():

i)Input: first name,fathers name,lastname,marks in all subjects out of 100

  initialize variable addtotal=0 initially  and  after adding marks of each subject increment   it  by 1.

Calculate percentage with addtotal variable value we get after adding all subjects marks.

Store this info in file ofstream addrec("Academics.csv", ios::app);

 

b)void viewrecord():

Input: prn-no(enrollment number )

Read file addrec("Academics.csv", ios::app); and compare our input with the records data using compare function as we have seen earlier.

if (inprn.compare(prn) == 0)

{

Cout<<”record found”<<endl;

//Display record of student

}

//End of academic record function

academic record : program

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <conio.h>

using namespace std;

// string name, fathername, lastname;
string rollno, prn, addname, addmname, addlname;
string se, co, oop, at, os, cn;
string fulname, perc;
string fullname;

void academicrec();

void addrec()
{
    int res, addtotal = 0;
    int se, co, oop, at, os, cn;

    cout << "Enter your first Name\n";
    cin >> addname;
    cout << "Enter your father's Name\n";
    cin >> addmname;
    cout << "Enter your Last Name\n";
    cin >> addlname;
    cout << "Enter your Roll No.\n";
    cin >> rollno;
    cout << "Enter your PRN:\n";
    cin >> prn;
SE:
    cout << "Enter marks obtained in SE(out of 100)\n";
    cin >> se;
    if (se > 100 || se < 1)
    {
        cout << "Number not in required parameters,Try again\n";
        goto SE;
    }
    addtotal = addtotal + se;
COA:
    cout << "Enter marks obtained in COA(out of 100)\n";
    cin >> co;
    if (co > 100 || co < 1)
    {
        cout << "Number not in required parameters,Try again\n";
        goto COA;
    }
    addtotal = addtotal + co;

OOP:
    cout << "Enter marks obtained in OOP(out of 100)\n";
    cin >> oop;
    if (oop > 100 || oop < 1)
    {
        cout << "Number not in required parameters,Try again\n";
        goto OOP;
    }
    addtotal = addtotal + oop;
AT:
    cout << "Enter marks obtained in AT(out of 100)\n";
    cin >> at;
    if (at > 100 || at < 1)
    {
        cout << "Number not in required parameters,Try again\n";
        goto AT;
    }
    addtotal = addtotal + at;
OS:
    cout << "Enter marks obtained in OS-I(out of 100)\n";
    cin >> os;
    if (os > 100 || os < 1)
    {
        cout << "Number not in required parameters,Try again\n";
        goto OS;
    }
    addtotal = addtotal + os;
CN:
    cout << "Enter marks obtained in CN-2(out of 100)\n";
    cin >> cn;
    if (cn > 100 || cn < 1)
    {
        cout << "Number not in required parameters,Try again\n";
        goto CN;
    }
    addtotal = addtotal + cn;
    // int total= se+co+oop+at+os+cn;
    cout << "Your Total marks are :" << addtotal << "/600" << endl;
    float perc = addtotal * 100 / 600;
    cout << "Your percentage is:" << perc << "%" << endl;
   ofstream addrec("Academics.csv", ios::app);
    fullname = addname + " " + addmname + " " + addlname;
    addrec << "\n"
           << fullname << "," << rollno << "," << prn << "," << se << "," << co << "," << oop << "," << at << "," << os << "," << cn << "," << perc;
    addrec.close();
}



void viewrec()
{

    int state = 0;
    string inprn;
    cout << "Enter PRN Number" << endl;
    cin >> inprn;
    ifstream find1("Academics.csv");
    while (find1.peek() != EOF)
    {

        getline(find1 >> ws, fulname, ',');
        getline(find1 >> ws, rollno, ',');
        getline(find1 >> ws, prn, ',');
        getline(find1 >> ws, se, ',');
        getline(find1 >> ws, co, ',');
        getline(find1 >> ws, oop, ',');
        getline(find1 >> ws, at, ',');
        getline(find1 >> ws, os, ',');
        getline(find1 >> ws, cn, ',');
        getline(find1 >> ws, perc, '\n');

        if (inprn.compare(prn) == 0)
        {
            cout << "Name: " << fulname << endl;
            cout << "Roll.No: " << rollno << endl;
            cout << "PRN Number: " << prn << endl;
            cout << "SE: " << se <<"/100"<< endl;
            cout << "COA: " << co << "/100"<<endl;
            cout << "OOP: " << oop <<"/100"<< endl;
            cout << "AT: " << at <<"/100"<< endl;
            cout << "OS: " << os << "/100"<<endl;
            cout << "CN:: " << cn <<"/100"<< endl;
            // cout<<"TOTAL MARKS:"<<(se+co)+(oop+at)+(os+cn)<<endl;
            cout << "total percentage: " << perc <<"%"<< endl;
            state = 2;
        }
    }
    if (state == 0)
    {
        cout << "Data Not found!";
        academicrec();
    }

    find1.close();
}

void deleteline1(const char *file_name, int n)
{
      // open file in read mode or in mode
    ifstream iss(file_name);

    // open file in write mode or out mode
    ofstream ofss;
    ofss.open("temp.txt", ofstream::out);

    // loop getting single characters
    char c;
    int line_no =1;
    while (iss.get(c))
    {
        // if a newline character
        if (c == '\n')
        line_no++;

        // file content not to be deleted
        if (line_no != n)
            ofss << c;
    }

    // closing output file
    ofss.close();

    // closing input file
    iss.close();

    // remove the original file
    remove(file_name);

    // rename the file
    rename("temp.txt", file_name);
}
void modifyrec()
{
   
    int n, state = 0;
    int i = 0;
    string rollnoo;
    ifstream file("Academics.csv");
    cout << "\nEnter the rollno. you want to Modify: ";
    cin >> rollnoo;
    while (file.peek() != EOF)
    {

        getline(file >> ws, fulname, ',');
        getline(file >> ws, rollno, ',');
        getline(file >> ws, prn, ',');
        getline(file >> ws, se, ',');
        getline(file >> ws, co, ',');
        getline(file >> ws, oop, ',');
        getline(file >> ws, at, ',');
        getline(file >> ws, os, ',');
        getline(file >> ws, cn, ',');
        getline(file >> ws, perc, '\n');
        i = i + 1;
        if (rollnoo.compare(rollno) == 0)
        {
            n = i;
            // file.close();
           
            state = 2;
        }
    }

    file.close();
    deleteline1("Academics.csv", n);
    addrec();
   
}

void academicrec()
{
     string username;
string adminpass;
    int res;
    cout << "\t\t\t\t*************************************\n";
    cout << "\t\t\t\t*************ACADEMICS**************\n";
    cout << "\t\t\t\t*************************************\n";
    cout << "\t\t\t1]Add academic record\n\t\t\t2]View Record\n\t\t\t3]Modify record\n";
    cout << "Enter your choice: ";
    cin >> res;
    switch (res)
    {
    case 1:
        addrec();
       
        break;

    case 2:
        viewrec();
        break;

    case 3:
        // cout << "Admin access only!!";
        // char a;
        // a = _getch();
        // switch (a)
        // {
        // case 38:
        // admin:
        //     cout << "\n\t\t\t******ADMIN LOGIN********\n";
        //     cout << "Enter Username" << endl;
        //     getline(cin >> ws, username);
        //     cout << "Enter Password" << endl;
        //     getline(cin >> ws, adminpass);
        //     if (username == "admin" && adminpass == "admin")
        //     {
        //         cout << "Admin login successfull\n";
        //     }
        //     else
        //     {
        //         cout << endl
        //              << "Data not found!!!\n"
        //              << endl;
        //         cout << "1.try again 2.exit\n";
        //         char u3;
        //     tryagain1:
        //         u3 = _getch();
        //         switch (u3)
        //         {
        //         case 49:;
        //             goto admin;
        //             break;
        //         case 50:
        //             cout << "Thank you for comming \n";
        //             exit(0);
        //             break; //code exits.
        //         default:
        //             goto admin;
        //             break;
        //         }
        //     }
           modifyrec();

             break;
           

            default:
                academicrec();
                break;
            }

        // default:
        // academicrec();
        //     break;
       
   
}

 

1 Comments

Previous Post Next Post