School Management System Project in C++With Source Code.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<fstream.h>
#include<dos.h>
Using namespace std;
Struct marks_criteria {
Int sc_min, com_min, arts_min, seat_sc, seat_com, seat_arts;
Crit;
Struct administrator {
Char user_name[10];
Char password[10];
}
Admin;
Struct student {
Char name[20];
Int regno, m_eng, m_math, m_sc, m_sst, m_lang;
Int pref_code, stream;
// Sc=1, Com=2; Arts=3;
Public:
Void new_file();
Void input_data();
Void allot_stream();
Int get_stream();
Void display();
Int show_per() {
Return ((m_eng + m_math + m_sc + m_sst + m_lang) / 5);
};
Void welcome();
Void menu();
Int verify_password();
Void assign_user();
Void clear();
Void input_criteria();
Void read_criteria();
Void read_student();
Void create_eligible_sc();
Void create_eligible_com();
Void create_eligible_arts();
Void read_eligible_sc();
Void read_eligible_com();
Void read_eligible_arts();
Char * stream_name(int strm);
Void select_list(char * in_file, char * out_file);
Void thanks();
Student s;
Main() {
// clrscr();
Welcome();
// cout<<”welcome”;
Fstream fin, fout;
Fstream fsc, fcom, farts;
Int opt = 1, ch;
While (opt != 8) {
// clrscr();
Clear();
Cout << “\n\t====================== MAIN MENU
=======================\n”;
Cout << “\n\t[1] CREATE / MODIFY ADMISSION CRITERIA(Administrator
only)”;
Cout << “\n\n\t[2] ENTER STUDENT’S DATA “;
Cout << “\n\n\t[3] ALLOTMENT OF STREAM”;
Cout << “\n\n\t[4] DISPLAY CRITERIA FOR SELECTION”;
Cout << “\n\n\t[5] DISPLAY ALLOTMENT OF STUDENT’S STREAM”;
Cout << “\n\n\t[6] DISPLAY ALL STUDENT’S REGISTERED”;
Cout << “\n\n\t[7] CREATE / DISPLAY MERIT LIST”;
Cout << “\n\n\t[8] QUIT”;
Cout << “\n\
t==============================================
===============\n”;
Cout << “\n\n\t\tEnter your choice : “;
Cin >> opt;
Switch (opt) {
Case 1:
Int p;
Assign_user();
P = verify_password();
If (p == 0) {
Input_criteria();
} else {
Cout << “\n\tU R Not a Valid User.”;
Cout << “\n\tU Don’t have the Authority to Create Question Bank. Bye\
n\n”;
Break;
Case 2:
Int option;
//clrscr();
Cout << “\nWhat do u want --\n\n\n\n\n\tCreate a new student
information file or Append to the existing file?\n\n\t(press 1 for new creation
and 2 for appending)”;
Cin >> option;
If (option == 1) {
s.new_file();
} else {
s.input_data();
Break;
Case 3:
//clrscr();
// read_student();
Fin.open(“student”, ios::in | ios::out);
Fsc.open(“elig_sc”, ios::out);
Fcom.open(“eligcom”, ios::out);
Farts.open(“eligart”, ios::out);
While (fin.read((char * ) & s, sizeof(s))) {
s.allot_stream();
s.get_stream();
//if(s.get_stream()==0)
Cout << “\nApplication Rejected. Not Eligible\n”;
If (s.get_stream() == 1)
Fsc.write((char * ) & s, sizeof(s));
If (s.get_stream() == 2)
Fcom.write((char * ) & s, sizeof(s));
If (s.get_stream() == 3)
Farts.write((char * ) & s, sizeof(s));
Fin.close();
Fsc.close();
Fcom.close();
Farts.close();
Cout << “\n*******************************************”;
Cout << “\n\n\tSTREAM ALLOCATION DONE.”;
Cout << “\n*******************************************”;
Break;
Case 4:
Read_criteria();
// clear();
Cout << “\n Sc : “ << crit.sc_min;
Cout << “\n Com : “ << crit.com_min;
Cout << “\n Sc : “ << crit.arts_min;
Break;
Case 5:
Cout << “\n Enter 1 for Sc, 2 for Com, 3 for Arts : “;
Cin >> ch;
If (ch == 1)
Read_eligible_sc();
If (ch == 2)
Read_eligible_com();
If (ch == 3)
Read_eligible_arts();
Break;
Case 6: //clrscr() ;
Read_student();
Break;
Case 7: {
Char c;
Int k = 1;
Cout << “\n****************************************”;
Cout << “\n****************************************”;
Cout << “\n M E R I T L I S T”;
Cout << “\n ==================”;
Cout << “\n\tEnter 1 for MERIT LIST SCIENCE “;
Cout << “\n\tEnter 2 for MERIT LIST COMMERCE “;
Cout << “\n\tEnter 3 for MERIT LIST ARTS \t”;
Cout << “\n****************************************”;
Cout << “\n****************************************”;
Cin >> k;
If (k == 1) {
Select_list(“elig_sc”, “sell_sc”);
Fin.open(“sell_sc”, ios::in);
If (k == 2) {
Select_list(“eligcom”, “sellcom”);
Fin.open(“sellcom”, ios::in);
If (k == 3) {
Select_list(“eligart”, “sellart”);
Fin.open(“sellart”, ios::in);
If (k >= 1 && k <= 3) {
While (fin.read((char * ) & s, sizeof(s))) {
s.display();
cout << “\n\t Continue (y/n)?”;
cin >> c;
if (c == ‘n’)
break;
Fin.close();
Fin.close();
Fin.close();
Break;
Case 8:
Thanks();
// cout<<”\nTHANKS BYE “;
// exit(0);
Break;
// END OF WHILE
Void assign_user() {
Strcpy(admin.user_name, “rimi”);
Strcpy(admin.password, “rimi”);
}
Int verify_password() {
Char u_name[10];
Char u_pwd[10], temp[2];
Int x = 1;
Cout << “\n\n Enter user name : “;
Cin >> u_name;
Cout << “\n\n Enter Password : “;
Cin >> u_pwd;
X = strcmp(admin.user_name, u_name);
If (x == 0) {
X = strcmp(admin.password, u_pwd);
Cin.getline(temp, 2);
Return (x);
Void student::allot_stream() {
Int per = (m_eng + m_math + m_sc + m_sst + m_lang) / 5;
Read_criteria();
Switch (pref_code) {
Case 1:
If (per >= crit.sc_min)
Stream = pref_code;
Else
Stream = 0;
Break;
Case 2:
If (per >= crit.com_min)
Stream = pref_code;
Else
Stream = 0;
Break;
Case 3:
If (per >= crit.arts_min)
Stream = pref_code;
Else
Stream = 0;
Break;
Int student::get_stream() {
Return (stream);
Void input_criteria() {
Fstream fout;
Fout.open(“criteria”, ios::in | ios::out);
Cout << “\nEnter the required marks for SCIENCE stream(in
percentage)”;
Cin >> crit.sc_min;
Cout << “\nEnter No. of Seats for SCIENCE stream”;
Cin >> crit.seat_sc;
Cout << “\nEnter the required marks for COMMERCE stream(in
percentage)”;
Cin >> crit.com_min;
Cout << “\nEnter No. of Seats for COMMERCE stream”;
Cin >> crit.seat_com;
Cout << “\nEnter the required marks for ARTS stream(in percentage)”;
Cin >> crit.arts_min;
Cout << “\nEnter No. of Seats for ARTS stream”;
Cin >> crit.seat_arts;
Fout.write((char * ) & crit, sizeof(crit));
Fout.close();
Void read_criteria() {
Fstream fin;
Fin.open(“criteria”, ios::in);
Fin.read((char * ) & crit, sizeof(crit));
Fin.close();
Void student::input_data() { //clrscr();
Fstream fin;
Fin.open(“student”, ios::app | ios::out);
Char t[2], ans;
While (1) {
Cout << “\nEnter the name of the student : “;
Cin >> name;
Cout << “\n\nEnter the roll of the student : “;
Cin >> regno;
Cout << “\n\nEnter marks in eng : “;
Cin >> m_eng;
Cout << “\n\nEnter marks in math : “;
Cin >> m_math;
Cout << “\n\nEnter marks in science : “;
Cin >> m_sc;
Cout << “\n\nEnter marks in sst : “;
Cin >> m_sst;
Cout << “\n\nEnter marks in language : “;
Cin >> m_lang;
Cout << “==================STREAM PREFERED?
================ \n”;
Cout << “\t” << “[1] for SCIENCE\n”;
Cout << “\t” << “[2] for COMMERCE\n”;
Cout << “\t” << “[3] for ARTS “;
Cout << “\
n=============================================
==== \n\tENTER PREFERENCE CODE : “;
Cin >> pref_code;
Stream = -1;
Fin.write((char * ) & s, sizeof(s));
Cin.getline(t, 2);
Cout << “\n\tEnter More Student ? (y/n)”;
Cin >> ans;
If (ans == ‘n’)
Break;
Fin.close();
Void student::new_file() { //clrscr();
Fstream fin;
Fin.open(“student”, ios::out);
Char t[2], ans;
While (1) {
Cout << “\nEnter the name of the student : “;
Gets(name);
Cout << “\n\nEnter the roll of the student : “;
Cin >> regno;
Cout << “\n\nEnter marks in eng : “;
Cin >> m_eng;
Cout << “\n\nEnter marks in math : “;
Cin >> m_math;
Cout << “\n\nEnter marks in science : “;
Cin >> m_sc;
Cout << “\n\nEnter marks in sst : “;
Cin >> m_sst;
Cout << “\n\nEnter marks in language : “;
Cin >> m_lang;
Cout << “==================STREAM PREFERED?
================ \n”;
Cout << “\t” << “[1] for SCIENCE\n”;
Cout << “\t” << “[2] for COMMERCE\n”;
Cout << “\t” << “[3] for ARTS “;
Cout << “\
n=============================================
==== \n\tENTER PREFERENCE CODE : “;
Cin >> pref_code;
Stream = -1;
Fin.write((char * ) & s, sizeof(s));
Cin.getline(t, 2);
Cout << “\n\tEnter More Student ? (y/n)”;
Cin >> ans;
If (ans == ‘n’)
Break;
Fin.close();
Void student::display() {
Cout << “\
n============================================\
n”;
Cout << “\n\tNAME : “ << name;
Cout << “\n\tREGISTRATION NO. : “ << regno;
Cout << “\n\tPERCENTAGE OF MARKS : “ << ((m_eng + m_math + m_sc +
m_sst + m_lang) / 5) << “%”;
Cout << “\n\tSTREAM APPLIED FOR : “ << stream_name(pref_code);
// cout<<”\n\tSTREAM ALLOTED : “<<stream_name(stream);
Cout << “\
n============================================\
n”;
Void read_student() {
Fstream fin;
Char c;
Fin.open(“student”, ios::in);
While (fin.read((char * ) & s, sizeof(s))) {
s.display();
cout << “\n\tPress any no. to continue “;
cin >> c;
cout << “\n”;
Fin.close();
Void read_eligible_sc() {
Char ans;
Fstream fout;
Fout.open(“elig_sc”, ios::in);
Fout.seekg(0);
While (fout.read((char * ) & s, sizeof(s))) {
s.display();
cout << “\n\t Continue (y/n)? “;
cin >> ans;
if (ans == ‘n’)
break;
Fout.close();
Void read_eligible_com() {
Char ans;
Fstream fout;
Fout.open(“eligcom”, ios::in);
While (fout.read((char * ) & s, sizeof(s))) {
s.display();
cout << “\n\t Continue (y/n)? “;
cin >> ans;
if (ans == ‘n’)
break;
}
Fout.close();
Void read_eligible_arts() {
Char ans;
Fstream fout;
Fout.open(“eligart”, ios::in);
While (fout.read((char * ) & s, sizeof(s))) {
s.display();
cout << “\n\t Continue (y/n)? “;
cin >> ans;
if (ans == ‘n’)
break;
Fout.close();
Void clear() {
// for(int i=1;i< =24;i++)
// cout<<”\n”;
Char * stream_name(int strm) {
Switch (strm) {
Case -1:
Return (“Not assigned”);
// break;
Case 0:
Return (“Nill”);
// break;
Case 1:
Return (“Science”);
// break;
Case 2:
Return (“Commerce”);
// break;
Case 3:
Return (“Arts”);
// break;
Default:
Return (“None”);
Void select_list(char * in_file, char * out_file) {
Fstream sel, fin;
Int n = 0, I, j;
Student sl[100], t;
Sel.open(out_file, ios::out);
Fin.open(in_file, ios::in);
While (fin.read((char * ) & sl[n], sizeof(s))) {
N++;
Cout << “\nNo of Eligible Students = “ << n << “\n”;
For (I = 0; I < n; i++) {
For (j = I + 1; j <= n; j++) {
If (sl[i].show_per() < sl[j].show_per()) {
T = sl[j];
Sl[j] = sl[i];
Sl[i] = t;
For (I = 0; I < n; i++) {
Sel.write((char * ) & sl[i], sizeof(s));
Sel.close();
Fin.close();
Void welcome() {
//clrscr();
Int z;
Cout << “\t%% %% “;
Cout << “\n\t%% %% %%%%%%% %% %%%%%% %%%%%% %%
%% %%%% %%%%%%%”;
Cout << “\n\t%% %% %% %% %% %% %% %% %%% %% %
% “;
Cout << “\n\t%% %% %% %%%%% %% %% %% %% %% %%%
%% %%%%% “;
Cout << “\n\t%% %% %% %% %% %% %% %% %% %% %
% “;
Cout << “\n\t%%%%%%%%%% %%%%%%% %%%%%%% %%%%%%%
%%%%%% %% %% %%%%%%% “;
Cout << “\n\n\t\t\t $$$$$$$$ $$$$$ “;
Cout << “\n\t\t\t $$ $ $ “;
Cout << “\n\t\t\t $$ $$$$$ “;
Cout << “\n\n\n\tCOMPUTER PROJECT (******** ON STREAM ALLOCATION
*******)”;
Cout << “ \n\n\n\t\t press any number and ‘ENTER’ to continue: “;
Cin >> z;
// getch();
Void thanks() {
Int w;
//clrscr();
Cout << “\n\n\n\n\n\n\n\n\n\n\t********** T H A N K Y O U F O R W O R
K I N G *******”;
Cout << “\n\n\n\n\n\n\n\t\t\t Press Any Number And Then ‘ENTER’ to exit”;
Cin >> w;
}