Вы находитесь на странице: 1из 8

/*libraries*/

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <windows.h>
#include <conio.h>
using namespace std;
const int adminPassword = 8080;
int totalStudents = 0;
int days = 0;
int const limit = 10; /* total number of students in record*/

/*---------------------------------------------------------------*/
/*Structure and strings for students data*/
struct student
{
string firstName;
string lastName;
int regnumber;
int studentPassword;
string address;
int phoneNumber;
string attendance;
}studentData[limit];

/*global variables for grades*/


double totalMarks = 50;
struct studentGrades/*marks structure*/
{
double cal = 0.0, cs = 0.0, phy = 0.0, geo = 0.0, eng = 0.0, is = 0.0;
//marks
double marksObtained = 0.0;
double percentage = 0.0;
}marks[6];

/
*----------------------------------------------------------------------------------
----------------------*/
/*Functions and their prototypes to be used*/
void grades();
void loginMenu();
void mainMenu();
void adminLogin();
void adminHome();
void newAccount();
void adminAttendance();
void studentInformation();
void studentLogin();
void studentHome(int x[]);
void studentAttendance();
void studentAttendance();
/
*----------------------------------------------------------------------------------
-----------------------*/
/*main function*/
int main()
{
/*login function runs just for one time, after this, it runs by calling
mainmenu function individually*/
int choice = 0;
cout << setw(20) << "LOGIN PAGE\n\n";
cout << "Please choose an option.\n";
cout << "______________________\n";
cout << "1. Admin Log in\n";
cout << "2. Student Log in\n";
cout << "3. Exit\n";
cout << "_______________________\n";
cout << "Enter your choice : ";
cin >> choice;
if (choice == 1)
{
adminLogin();
}
else if (choice == 2)
{
studentLogin();
}
else if (choice == 3)
{
cout << "Press Ctrl+Z to exit\n";
}
choice = 0;
return 0;
}
/*
-----------------------------------------------------------------------------------
------------*/
/*login menu function*/
void loginMenu()
{
int choice = 0;
cout << setw(20) << "LOGIN PAGE" << "\n";
cout << "Please choose an option." << "\n";
cout << "_______________________" << endl;
cout << "1. Admin Log in\n";
cout << "2. Student Log in\n";
cout << "3. Exit\n";
cout << "______________________" << endl;
cout << "Enter your choice :" << endl;
cin >> choice;
if (choice == 1)
{
adminLogin();
}
else if (choice == 2)
{
studentLogin();
}
else if (choice == 3)
{
cout << "Press Ctrl+Z and the Enter to Exit.\n";
}
choice = 0;
}
/*---------------------------------------------------------------------*/
/*admin login function*/
void adminLogin()
{
int choice = 0;
int password = 0;
cout << "Enter Admin Password : ";
cin >> password;
if (password == adminPassword)
{
adminHome();
}
else if (password != adminPassword)
{
cout << "Your password is wrong. Try again." << endl;
adminLogin();
}
choice = 0;
cin.get();
}
/*--------------------------------------------------------------*/
/*Admin home page*/
void adminHome()
{
int choice = 0;
cout << "\n\nWELCOME! ADMIN\n\n";
cout << "Please choose an option\n";
cout << "___________________________\n";
cout << "1. New Student Account\n";
cout << "2. Edit Student Information\n";
cout << "3. Today's Attendance\n";
cout << "4. Back\n";
cout << "_________________________________\n";
cout << "Enter your choice :" << endl;
cin >> choice;
if (choice == 1)
{
newAccount();
}
else if (choice == 2)
{
studentInformation();
}
else if (choice == 3)
{
adminAttendance();
}
else if (choice == 4)
{
loginMenu();
}
choice = 0;
}
/*--------------------------------------------------------------*/
/*new student account used by admin*/
void newAccount()
{
int choice = 0;
cout << "Create a new student account\n\n";
cin.ignore();
cout << "Enter First Name : ";
cin >> studentData[totalStudents].firstName;
cout << "Enter Last Name : ";
cin >> studentData[totalStudents].lastName;
cout << "Registration Number : ";
cin >> studentData[totalStudents].regnumber;
cout << "New Password : ";
cin >> studentData[totalStudents].studentPassword;
cout << "Phone Number : ";
cin >> studentData[totalStudents].phoneNumber;
cout << "Address :";
cin >> studentData[totalStudents].address;
totalStudents++;
/*increment of number of students*/
cout << "Do you want to make another student account? Then press 1\n";
cout << "OR Press 2 to return back\n";
cin >> choice;
if (choice == 1)
{
newAccount();
}

else if (choice == 2)
{
adminHome();
}
choice = 0;
}
/
*----------------------------------------------------------------------------------
-----*/
/* student information used by admin*/
void studentInformation()
{
int choice = 0;
int findRegNumber;
cout << "Enter Registration Number of the Student : ";
cin >> findRegNumber;
for (int i = 0; i < totalStudents; i++)
{
if (findRegNumber == studentData[i].regnumber)
{
cout << "\nPlease choose an option : \n";
cout << "_________________________________\n";
cout << "1. Grades\n";
cout << "2. Attendance\n";
cout << "3. Back\n";
cout << "_________________________________\n";
cout << "Enter your choice : ";
cin >> choice;
if (choice == 1)
{
grades();
}
else if (choice == 2)
{
adminAttendance();
}
else if (choice == 3)
{
adminHome();
}
break;
choice = 0;
}
else if (findRegNumber != studentData[i].regnumber)
{
cout << "No such record found\n";
cin.get();
}

}
}

/
*----------------------------------------------------------------------------------
----------*/
/*student home page function*/

void studentHome(int x[],totalStudents)

{
cout << "Welcome! " << studentData[i].firstName << " " <<
studentData[i].lastName << "\n";
int choice = 0;
cout << setw(20) << "HOME PAGE" << "\n";
cout << "Please choose an option" << "\n";
cout << "____________________\n";
cout << "1. Information \n";
cout << "2. Attendance\n";
cout << "3. Grades\n";
cout << "4. Back\n";
cout << "____________________\n";
cout << "Enter your choice : ";
cin >> choice;
if (choice == 1)
{
cout << "First Name : ";
cin >> studentData[i].firstName;
cout << "Last Name : ";
cin >> studentData[i].lastName;
cout << "Registration Number : ";
cin >> studentData[i].regnumber;
cout << "Password : ";
cin >> studentData[i].studentPassword;
cout << "Phone Number : ";
cin >> studentData[i].phoneNumber;
cout << "Address :";
cin >> studentData[i].address;
}
else if (choice == 2)
{
studentAttendance();
}

else if (choice == 3)
{
cout << "\nMARKS OF YOUR SUBJECTS \n ";
cout << "Total Marks of each subject : 50\n";
cout << "Calculus : ";
cout << marks[totalStudents].cal;
cout << "Fundamentals of Programming : ";
cout << marks[totalStudents].cs;
cout << "Physics : ";
cout << marks[totalStudents].phy;
cout << "Geography : ";
cout << marks[totalStudents].geo;
cout << "English : ";
cout << marks[totalStudents].eng;
cout << "Islamic Studies : ";
cout << marks[totalStudents].is;
marks[totalStudents].marksObtained = marks[totalStudents].cal +
marks[totalStudents].cs + marks[totalStudents].phy + marks[totalStudents].geo +
marks[totalStudents].eng + marks[totalStudents].is;
marks[totalStudents].percentage = ((marks[totalStudents].marksObtained)
/ (totalMarks * 6)) * 100;
cout << "Total Marks : " << totalMarks * 6;
cout << "\nMarks Obtained : " << marks[totalStudents].marksObtained;
cout << "\nPercentage : " << marks[totalStudents].percentage;

if (marks[totalStudents].percentage >= 50.0)


{
cout << "\n\nPASS\n" << endl;
}
else if (marks[totalStudents].percentage < 50.0)
{
cout << "\n\nFAIL" << endl;
}
choice = 0;
cout << "\nPress 1 to return Back.\n";
cin >> choice;
if (choice == 1)
{
studentHome();
}
choice = 0;
}

else if (choice == 4)
{
loginMenu();
}
choice = 0;
}
/
*----------------------------------------------------------------------------------
------*/
/*student login*/
void studentLogin()
{
int regnumber, password;
cout << "Enter Your Regitration Number : ";
cin >> regnumber;
cout << "Enter you password : ";
cin >> password;
for (int i = 0; i < totalStudents; i++)
{
if (regnumber == studentData[i].regnumber)
{
if (password == studentData[i].studentPassword)
{
studentHome(studentData[i].regnumber);
}
else
{
cout << "Wrong login details!\n";
loginMenu();
}
}
}
}
/*-----------------------------------------------------------------------*/
void adminAttendance()
{
for (int i = 0; i < totalStudents; i++)

{
cout << studentData[i].regnumber << " " << studentData[i].firstName <<
" " << studentData[i].lastName << "\n";
cin >> studentData[i].attendance;
cout << "\n";
}
days++;
}
/*-------------------------------------------------------------------------*/

void studentAttendance()
{
cout << "Present : p \n";
cout << "Absent : a \n";
cout << studentData[totalStudents].regnumber << " " <<
studentData[totalStudents].firstName << " " << studentData[totalStudents].lastName
<< endl;
for (int i = 0; i < days; i++)
{
cout << "Day " << i + 1 << studentData[i].attendance << "\n";
}
}
/*-------------------------------------------------------*/

void grades()
{
int choice = 0;
cout << "\n ENTER MARKS OF THE FOLLOWING SUBJECTS \n ";
cout << "Total Marks of each subject : 50\n";
cout << "Calculus : ";
cin >> marks[totalStudents].cal;
cout << "Fundamentals of Programming : ";
cin >> marks[totalStudents].cs;
cout << "Physics : ";
cin >> marks[totalStudents].phy;
cout << "Geography : ";
cin >> marks[totalStudents].geo;
cout << "English : ";
cin >> marks[totalStudents].eng;
cout << "Islamic Studies : ";
cin >> marks[totalStudents].is;
marks[totalStudents].marksObtained = marks[totalStudents].cal +
marks[totalStudents].cs + marks[totalStudents].phy + marks[totalStudents].geo +
marks[totalStudents].eng + marks[totalStudents].is;
marks[totalStudents].percentage = ((marks[totalStudents].marksObtained) /
(totalMarks * 6)) * 100;
cout << "Total Marks : " << totalMarks * 6;
cout << "\nMarks Obtained : " << marks[totalStudents].marksObtained;
cout << "\nPercentage : " << marks[totalStudents].percentage;

if (marks[totalStudents].percentage >= 50.0)


{
cout << "\n\nPASS\n" << endl;
}
else if (marks[totalStudents].percentage < 50.0)
{
cout << "\n\nFAIL" << endl;
}
cin.get();
cout << "\nPress 1 to return back : ";
cin >> choice;
if (choice == 1)
{
adminHome();
}
choice = 0;
}

Вам также может понравиться