Code:
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <conio.h>
#include <string>
#include <fstream>
#include <windows.h>
using namespace std;
/******************************************************************************************************/
/************************************** PROTOTYPES OF FUNCTIONS ***************************************/
/******************************************************************************************************/
void menu();
void studentInfo();
void attendanceRecord();
void disC();
void hod();
void arrangeMeeting();
void filewrite();
void search();
/***************************************** END OF PROTOTYPES ******************************************/
/******************************************************************************************************/
/*********************************** DEFINITION OF VARIABLES ******************************************/
/******************************************************************************************************/
char *rollNumber= new char[100];
char *studentName= new char[100];
char *fathersName= new char[100];
char *dob= new char[50];
char *enrollmentDate= new char[50];
char *batch= new char[20];
char *department= new char[50];
float semester[9][6]={100,100,100,100,100,100};
int offences=1;
int *natOffences= new int [100];
int fine = 0 ;
int sem;
int warning;
int appProcess[5][5]={0,0,0,0,0};
int appcount=0;
int *sick=new int [500];
int *shrtatnd=new int[500];
int *drop=new int[500];
int sickcounter=0;
int dropcounter=0;
int shrtatndcounter=0;
int criticality[4]={0,0,0,0};
int attendancecheck=0;
/***************************************** END OF DEFINITIONS *****************************************/
/******************************************************************************************************/
/****************************************** MAIN FUNCTION *********************************************/
/******************************************************************************************************/
main()
{
int opt;
system("color 03");
system("cls");
cout<<" __ __ _ _ __ __ "<<endl;
cout<<" / / \\ | | | |__ * |__ "<<endl;
cout<<" \\__ \\__/ | | | __| | __| "<<endl;
cout<<"\n\n"<<setw(50)<<"Welcome to COMSiS\n"<<setw(60)<< "COMSATS Atd Student Management System";
cout<<"\n\n********************************************************************************";
cout<<"\n"<<setw(80)<<"Written by BILAL & AQIB.\n";
cout<<"********************************************************************************\n";
cout<<"ENTER CORRESPONDING NUMBER FOR DESIRED OPTION \n"<<endl;
cout<<"1-View Existing Record\n2-Enter New Record"<<endl;
cout<<"\n********************************************************************************\n=";
cin>> opt;
switch (opt)
{
case 1 :
{
cout<<"Enter Roll No. of Student: (For Example \"FA12-BSE-275\")\n";
cin>>rollNumber;
search();
break;
}
case 2:
{
cout<<"Enter Roll No. of Student: (For Example \"FA12-BSE-275\")\n";
cin>>rollNumber;
menu();
}
}
}
/***************************************** END OF FUNCTION *******************************************/
/******************************************************************************************************/
/***************************************** MENU FUNCTION **********************************************/
/******************************************************************************************************/
void menu()
{
system("cls");
int opt ;
int x=0 ;
cout<<setw(78)<<" ** COMSiS **" <<endl;
do
{
system("cls");
cout<<setw(78)<<" ** COMSiS **" <<endl;
cout<<endl ;
cout<<"ENTER CORRESPONDING NUMBER FOR DESIRED OPTION \n"<<endl;
cout<<"1- Student Info \n2- Attendance Record \n3- Disciplinary Committee Records \n" << endl ;
cin>> opt ;
switch (opt)
{
case 1:
{
studentInfo(); //FUNCTION CALL TO VIEW OR EDIT STUDENT INFO
break;
}
case 2:
{
attendanceRecord(); //FUNCTION CALL TO VIEW OR EIDT ATTENDANCE RECORD OF STUDENT
break;
}
case 3:
{
disC(); //FUNCTION CALL TO VIEW OR EDIT THE DISCIPLINARY RECORD OF STUDENT
break;
}
default:
{
cout<<"Invalid option entered.\nPlease enter a valid option.\n\n";
}
}
filewrite();
} while (x==0);
}
/***************************************** END OF FUNCTION *******************************************/
/******************************************************************************************************/
/************************************* STUDENT INFO FUNCTION ******************************************/
/******************************************************************************************************/
void studentInfo()
{
int opt ;
system("cls");
cout<<setw(78)<<" ** COMSiS **" <<endl;
/* PROMPTING USER TO CHOOSE DESIRED ACTION */
cout<<"Do you want to view or edit the information?\nPlease enter 1 to view and 2 to edit : "<<endl;
cin>>opt;
switch (opt)
{
case 1:
{
/* PRINTING ALL DATA TAKEN FROM THE USER FOR THE CURRENT STUDENT */
cout<<"\nStudent's Full Name: "<<studentName;
cout<<"\nFather's Full Name: "<<fathersName;
cout<<"\nStudent's Date Of Birth (DD/MM/YY): "<<dob;
cout<<"\nStudent's Date of Enrollment: "<<enrollmentDate;
cout<<"\nBatch of Student: "<<batch;
cout<<"\nDepartment of Student: "<<department;
/*PRINTING SEMESTER WISE GPA OF STUDENT */
if (sem>1)
{
cout<<"\nStudent's Semester-wise GPA: ";
for (int i=1; i<sem; i++)
{
cout<<"\nGPA of Semester "<<i<<" is: ";
}
}
cout<<"\nPlease enter any key to go back to the main menu."<<endl;
getche();
break;
}
case 2:
{
cin.ignore();
/* TAKING ALL DATA FROM USER */
cout<<"Enter Student's Full Name: ";
cin.getline(studentName , 30 , '\n');
cout<<"\nEnter Father's's Full Name: ";
cin.getline( fathersName , 30 , '\n');
cout<<"\nEnter Student's Date Of Birth (DD/MM/YY): ";
cin.getline( dob , 80 , '\n');
cout<<"\nEnter Student's Date of Enrollment: ";
cin.getline( enrollmentDate , 80 , '\n');
cout<<"\nEnter Batch of Student: " ;
cin.getline( batch , 80 , '\n');
cout<<"\nEnter Department of Student: " ;
cin.getline( department, 80 , '\n');
cout<<"\nEnter current semester of the student: ";
cin>>sem;
/* TAKING SEMESTER WISE GPA FROM THE USER */
if (sem>1)
{
cout<<"\nEnter Student's Semester-wise GPA: ";
for (int i=1; i<sem; i++)
{
cout<<"\nEnter GPA of Semester "<<i<<": ";
cin>>semester[i][0];
}
}
/* RETURNING TO MAIN MENU AFTER THE COMPLETION OF TASK */
cout<<"\n\nPress any key to go back to main menu"<<endl;
getche();
cout<<semester[0][0];
break;
}
default:
{
cout<<"\nPlease enter a valid option.\n";
getche();
}
}
/***************************************** END OF FUNCTION *******************************************/
/******************************************************************************************************/
/*********************************** ATTENDANCE RECORD FUNCTION ***************************************/
/******************************************************************************************************/
}
void attendanceRecord()
{
system("cls");
cout<<setw(78)<<" ** COMSiS **" <<endl;
int opt;
/* PROMPTING USER TO CHOOSE DESIRED ACTION */
cout<<"Do you want to view or edit the information?\nPlease enter 1 to view and 2 to edit : "<<endl;
cin>>opt;
switch (opt)
{
case 1:
{
for ( int i=sem ; i<=sem ; i++ )
{
for (int j=1 ; j<=5 ; j++ )
{
cout <<"\nPercentage Attendance In Course "<<j<<" Of Current Semester "<<i<<":"<<semester[i][j];
}
}
cout<<"\nPlease enter any key to go back to the main menu."<<endl;
getche() ;
break;
}
case 2:
{
cout<<"Enter Percentage Attendence of Each Course" <<endl ;
cout<<"\nEnter Current Semester"<<endl ;
cin>> sem ;
for ( int i=sem ; i<=sem ; i++ )
{
for (int j=1 ; j<=5 ; j++ )
{
cout <<"\nEnter Percentage Attendance In Course "<<j<<" Of Current Semester "<<i<<":";
cin>> semester[i][j] ;
}
}
break ;
}
/* RETURNING TO MAIN MENU AFTER THE COMPLETION OF TASK */
cout<<"\nPlease enter any key to go back to the main menu."<<endl;
getche();
}
}
/***************************************** END OF FUNCTION *******************************************/
/******************************************************************************************************/
/************************************ DISCIPLINARY RECORD FUNCTION ************************************/
/******************************************************************************************************/
void disC()
{
system("cls");
cout<<setw(78)<<" ** COMSiS **" <<endl;
int opt;
/* PROMPTING USER TO CHOOSE DESIRED ACTION */
cout<<"Do you want to view or edit the information?\nPlease enter 1 to view and 2 to edit : "<<endl;
cin>>opt;
switch (opt)
{
case 1:
{
cout<<"\nNumber of Offences: "<<offences;
for (int i=0; i<offences; i++)
{
cout<<"\nNature of offence "<<i+1<<"is: ";
switch (natOffences[i])
{
case 1 :
{
cout<<"\nSmoking\\Drugs\n";
cout<<" FINE : Rs 2000"<<endl ;
break ;
}
case 2 :
{
cout<<"\nCheating\n";
cout<<" FINE : Rs 2000"<<endl ;
break ;
}
case 3 :
{
cout<<"\nLoss of University Card\n";
cout<<" FINE : Rs 500"<<endl ;
break;
}
case 4 :
{
cout<<"\nFighting\n";
cout<<" FINE : Rs 2000"<<endl ;
break ;
}
case 5 :
{
cout<<"\nDamaging University Property\n";
cout<<" FINE : Rs 2000"<<endl ;
break ;
}
case 6 :
{
cout<<"\nStealing\n";
cout<<" FINE : Rs 2000"<<endl ;
break ;
}
case 7 :
{
cout<<"\nMisbehaviour with Faculty\n";
cout<<" FINE : Rs 2000"<<endl ;
break ;
}
}
}
cout<<"\nPress any key to go back to the main menu."<<endl;
getche();
break;
}
case 2:
{
cout<<"Enter Number of Offences: ";
cin>>offences;
cout<<"\nPlease enter the corresponding number to the nature of offence\n1- Smoking\\Drugs\n2- Cheating\n3- Loss of university card\n4- Fighting\n5- Damaging university property\n6- Stealing\n7- Misbehaviour with faculty"<<endl ;
for (int i=0; i<offences; i++)
{
cout<<"\n Enter nature of offence "<<i+1<<": ";
cin>>natOffences[i];
switch (natOffences[i])
{
case 1 :
{
cout<<" FINE : Rs 2000"<<endl ;
fine += 2000 ;
break ;
}
case 2 :
{
cout<<" FINE : Rs 2000"<<endl ;
fine += 2000 ;
break ;
}
case 3 :
{
cout<<" FINE : Rs 500"<<endl ;
fine += 500 ;
break ;
}
case 4 :
{
cout<<" FINE : Rs 2000"<<endl ;
fine += 2000 ;
break ;
}
case 5 :
{
cout<<" FINE : Rs 2000"<<endl ;
fine += 2000 ;
break ;
}
case 6 :
{
cout<<" FINE : Rs 2000"<<endl ;
fine += 2000 ;
break ;
}
case 7 :
{
cout<<" FINE : Rs 2000"<<endl ;
fine += 2000 ;
break ;
}
}
}
cout<<"\nTOTAL FINE PAID: "<<fine<<endl;
}
}
/* RETURNING TO MAIN MENU AFTER THE COMPLETION OF TASK */
cout<<"\nPress any key to go back to the main menu"<<endl;
getche();
}
/***************************************** END OF FUNCTION *******************************************/
/******************************************************************************************************/
/************************************** FILE WRITING FUNCTION *****************************************/
/******************************************************************************************************/
void filewrite()
{
ofstream input;
input.open("bilalzaman.txt", ios::app);
input<<rollNumber<<","<<studentName<<","<<fathersName<<","<<dob<<","<<enrollmentDate<<","<<batch<<","<<department<<","<<offences<<","<<fine<<","<<sem<<","<<warning<<",";
for ( int i=1 ; i<2 ; i++)
{
for ( int j=0 ; j<6 ; j++)
{
input<<semester[i][j]<<"," ;
}
}
input<<endl;
input.close();
}
/***************************************** END OF FUNCTION ********************************************/
void search()
{
system("cls");
cout<<setw(78)<<" ** COMSiS **" <<endl;
int x=0;
char *a= new char [500];
char *b= new char [500];
char *c= new char [500];
char *k= new char [100];
ifstream fileread;
fileread.open ("bilalzaman.txt", ios::in);
while (!fileread.eof())
{
fileread.getline(a, 10000000, '\n');
b=strtok(a, ",");
*k= *b;
if (*k==*rollNumber)
{
cout<<"Record Found\n\n\n";
studentName=strtok(NULL,",");
fathersName=strtok(NULL,",");
dob=strtok(NULL,",");
enrollmentDate=strtok(NULL,",");
batch=strtok(NULL,",");
department=strtok(NULL,",");
offences=atoi (strtok(NULL,","));
fine=atoi (strtok(NULL,","));
sem=atoi (strtok(NULL,","));
warning=atoi (strtok(NULL,","));
semester[1][0]=atoi (strtok(NULL,","));
semester[1][1]=atoi (strtok(NULL,","));
semester[1][2]=atoi (strtok(NULL,","));
semester[1][3]=atoi (strtok(NULL,","));
semester[1][4]=atoi (strtok(NULL,","));
semester[1][5]=atoi (strtok(NULL,","));
cout<<"Roll no : "<<rollNumber<<"\nName : "<<studentName<<"\nFather's Name : "<<fathersName<<"\nD.O.B : "<<dob<<"\nEnrollment Date : "<<enrollmentDate<<"\nBatch : "<<batch<<"\nDept. : "<<department<<"\nNo. of Offences : "<<offences<<"\nTotal Fine Paid : "<<fine<<"\nCurrent Semester : "<<sem<<"\nNo. of Warnings : "<<warning<<"\nGPA : "<<semester[1][0]<<"\n";
for ( int i=1 ; i<2 ; i++)
{
cout<<"ATTENDANCE FOR THE 5 COURSES IS AS FOLLOWS :-"<<endl;
for ( int j=1 ; j<6 ; j++)
{
cout<<semester[i][j]<<"," ;
}
cout<<endl;
}
getche();
fileread.close();
break;
}
}
}