0% found this document useful (0 votes)
22 views27 pages

22f-3672 CP Ayesha

The document defines a Student class with attributes like name, roll number, marks in different subjects, percentage, grade and GPA. It includes functions to get/set data, calculate results, display results and write/read students to a binary file. The main function provides a menu to write, display, modify, delete students or view class results by reading the data file. It also includes user authentication with a username and password check before allowing actions.

Uploaded by

Qura tul Ain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views27 pages

22f-3672 CP Ayesha

The document defines a Student class with attributes like name, roll number, marks in different subjects, percentage, grade and GPA. It includes functions to get/set data, calculate results, display results and write/read students to a binary file. The main function provides a menu to write, display, modify, delete students or view class results by reading the data file. It also includes user authentication with a username and password check before allowing actions.

Uploaded by

Qura tul Ain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Ayesha Naseer 22f-3672

Result card management system


#include<iostream>
#include<fstream>
#include<iomanip>
#include <windows.h>
using namespace std;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
class Student
{
int rollno;
char name[50];
float oop_marks, ds_marks, ise_marks, eng_marks, is_marks;
double per;
char grade;
float gpa;

public:
void getdata();
void showdata() const;
void calculate();
Ayesha Naseer 22f-3672

void show_tabular() const;

int getRollNo() const {


return rollno;
}
const char* getName() const
{
return name;
}
float getOopMarks() const {
return oop_marks;
}

float getDsMarks() const {


return ds_marks;
}

float getIseMarks() const {


return ise_marks;
}
Ayesha Naseer 22f-3672

float getEngMarks() const {


return eng_marks;
}

float getISMarks() const {


return is_marks;
}

double getPercentage() const {


return per;
}

char getGrade() const {


return grade;
}

float getGpa() const {


return gpa;
}
};
Ayesha Naseer 22f-3672

void Student::calculate()
{
per = (oop_marks + ds_marks + ise_marks + eng_marks + is_marks) / 5.0;
if (per >= 85) {
grade = 'A';
gpa = 4;
}
else if (per >= 75) {
grade = 'B';
gpa = 3.33;
}
else if (per >= 65) {
grade = 'C';
gpa = 2.66;
}
else if (per >= 50) {
grade = 'D';
gpa = 2;
}
else
Ayesha Naseer 22f-3672

grade = 'F';
}

void Student::getdata()
{
cout << "\nEnter The roll number of student ";
cin >> rollno;
cout << "\nEnter The Name of student ";
cin.ignore();
cin.getline(name, 50);
cout << "\nEnter The marks in OOP out of 100: ";
cin >> oop_marks;
cout << "\nEnter The marks in DS out of 100: ";
cin >> ds_marks;
cout << "\nEnter The marks in ISE out of 100: ";
cin >> ise_marks;
cout << "\nEnter The marks in ENG out of 100: ";
cin >> eng_marks;
cout << "\nEnter The marks in IS out of 100: ";
cin >> is_marks;
Ayesha Naseer 22f-3672

calculate();
}

void Student::showdata() const


{
cout << "\nRoll number of student: " << rollno;
cout << "\nName of student: " << name;
cout << "\nMarks in OOP: " << oop_marks;
cout << "\nMarks in DS: " << ds_marks;
cout << "\nMarks in ISE: " << ise_marks;
cout << "\nMarks in ENG: " << eng_marks;
cout << "\nMarks in IS: " << is_marks;
cout << "\nPercentage of student: " << per;
cout << "\nGrade of student: " << grade;
cout << "\nGPA of student: " << gpa;
}

void Student::show_tabular() const


{
cout << rollno << setw(6) << " " << name << setw(11) << oop_marks << setw(9) << ds_marks <<
setw(9) << ise_marks << setw(9)
<< eng_marks << setw(9) << is_marks << setw(8) << per << setw(7) << grade << setw(9)
<< gpa << endl;
Ayesha Naseer 22f-3672

void write_student()
{
Student st;
ofstream outFile;
outFile.open("student.txt", ios::app);
st.getdata();
outFile.write(reinterpret_cast<char*> (&st), sizeof(Student));
outFile.close();
cout << "\n\nStudent record Has Been Created ";
cin.ignore();
cin.get();
}

void display_all()
{
Student st;
ifstream inFile;
inFile.open("student.txt", ios::binary);
Ayesha Naseer 22f-3672

if (!inFile)
{
cout << "File could not be open !! Press any Key...";
cin.ignore();
cin.get();
return;
}
cout << "\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n";
while (inFile.read(reinterpret_cast<char*> (&st), sizeof(Student)))
{
st.showdata();
cout << "\n\n====================================\n";
}
inFile.close();
cin.ignore();
cin.get();
}

void display_sp(int n)
{
Student st;
Ayesha Naseer 22f-3672

ifstream inFile;
inFile.open("student.txt", ios::app);
if (!inFile)
{
cout << "File could not be open !! Press any Key...";
cin.ignore();
cin.get();
return;
}
bool flag = false;
while (inFile.read(reinterpret_cast<char*> (&st), sizeof(Student)))
{
if (st.getRollNo() == n)
{
st.showdata();
flag = true;
}
}
inFile.close();
if (flag == false)
cout << "\n\nrecord not exist";
Ayesha Naseer 22f-3672

cin.ignore();
cin.get();
}

void modify_student(int n)
{
bool found = false;
Student st;
fstream File;
File.open("student.txt", ios::app | ios::in | ios::out);
if (!File)
{
cout << "File could not be open !! Press any Key...";
cin.ignore();
cin.get();
return;
}
while (!File.eof() && found == false)
{

File.read(reinterpret_cast<char*> (&st), sizeof(Student));


Ayesha Naseer 22f-3672

if (st.getRollNo() == n)
{
st.showdata();
cout << "\n\nPlease Enter The New Details of student" << endl;
st.getdata();
int pos = (-1) * static_cast<int>(sizeof(st));
File.seekp(pos, ios::cur);
File.write(reinterpret_cast<char*> (&st), sizeof(Student));
cout << "\n\n\t Record Updated";
found = true;
}
}
File.close();
if (found == false)
cout << "\n\n Record Not Found ";
cin.ignore();
cin.get();
}

void delete_student(int n)
{
Ayesha Naseer 22f-3672

Student st;
ifstream inFile;
inFile.open("student.txt", ios::app);
if (!inFile)
{
cout << "File could not be open !! Press any Key...";
cin.ignore();
cin.get();
return;
}
ofstream outFile;
outFile.open("Temp.txt", ios::out);
inFile.seekg(0, ios::beg);
while (inFile.read(reinterpret_cast<char*> (&st), sizeof(Student)))
{
if (st.getRollNo() != n)
{
outFile.write(reinterpret_cast<char*> (&st), sizeof(Student));
}
}
outFile.close();
Ayesha Naseer 22f-3672

inFile.close();
remove("student.txt");
rename("Temp.txt", "student.txt");
cout << "\n\n\tRecord Deleted ..";
cin.ignore();
cin.get();
}

void class_result()
{
Student st;
ifstream inFile;
inFile.open("student.txt", ios::app);
if (!inFile)
{
cout << "File could not be open !! Press any Key...";
cin.ignore();
cin.get();
return;
}
cout << "\n\n\t\t\t\tALL STUDENTS RESULT \n\n";
Ayesha Naseer 22f-3672

cout <<
"====================================================================================
====\n";
cout << "R.No Name OOP DS ISE ENG IS %age Grade GPA" << endl;
cout <<
"====================================================================================
====\n";
while (inFile.read(reinterpret_cast<char*> (&st), sizeof(Student)))
{
st.show_tabular();
}
cin.ignore();
cin.get();
inFile.close();
}

bool authenticate(const string& username, const string& password) {


if (username == "ayesha" && password == "3672") {
return true;
}
else {
return false;
}
}
Ayesha Naseer 22f-3672

int main()
{
char ch;
cout.setf(ios::fixed | ios::showpoint);
cout << setprecision(2);
string username, password;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 1);
cout << "**************************************" << endl;
cout << " Login Page " << endl;
cout << "**************************************" << endl;

bool check = false;


int count = 0;
do
{
SetConsoleTextAttribute(hConsole, 2);
count++;
cout << "Please enter your credentials." << endl;
cout << "Username: ";
cin >> username;
Ayesha Naseer 22f-3672

cout << "Password: ";


cin >> password;
check = (authenticate(username, password));

} while (count < 3 && check == false);


if (check == true)
{
do
{
system("cls");
cout << "\
n************************************************************\n";
cout << " MAIN MENU";
cout << "\
n************************************************************\n";
SetConsoleTextAttribute(hConsole, 3);
cout << "\n\t01. Result";
cout << "\n\t02. Entry";
cout << "\n\t03. Exit";
cout << "\n\tEnter Choice: ";
cin >> ch;
switch (ch)
{
Ayesha Naseer 22f-3672

case '1':
char ch;
int rno;
system("cls");
cout << "\n\
n************************************************************\n";
cout << "\t\tRESULT MENU";
cout << "\
n************************************************************\n";
cout << "\n\n\n\t1. Class Result";
cout << "\n\n\t2. Student Report Card";
cout << "\n\n\t3. Back to Main Menu";
cout << "\n\n\n\tEnter Choice (1/2/3)? ";
cin >> ch;
system("cls");
switch (ch)
{
case '1':
system("cls");
SetConsoleTextAttribute(hConsole, 5);
cout << "\n\
n************************************************************************************
****\n";
cout << "\t\t\t\tCLASS REPORT";
cout << "\
n************************************************************************************
****\n";
Ayesha Naseer 22f-3672

class_result();
break;
case '2':
system("cls");
SetConsoleTextAttribute(hConsole, 5);
cout << "\n\
n************************************************************\n";
cout << "\t\t\tSTUDENT REPORT CARD";
cout << "\
n************************************************************\n";
cout << "\n\n\tEnter Roll Number Of Student : ";
cin >> rno;
display_sp(rno);
break;
case '3':
break;
default:
cout << "\a";
}
break;
case '2':

char ch;
Ayesha Naseer 22f-3672

int num;
system("cls");
SetConsoleTextAttribute(hConsole, 5);
cout << "\n\
n************************************************************\n";
cout << "\t\t\tENTRY MENU";
cout << "\
n************************************************************\n";
cout << "\n\n\t1.Create Student Record";
cout << "\n\t2.Display all Student Record";
cout << "\n\t3.Search Student Record";
cout << "\n\t4.Modify Student Record";
cout << "\n\t5. Delete Student Record";
cout << "\n\t6.Back to Main Menu";
cout << "\n\tPlease Enter Your Choice (1-6) ";
cin >> ch;
system("cls");
switch (ch)
{
case '1':
system("cls");
SetConsoleTextAttribute(hConsole, 6);
Ayesha Naseer 22f-3672

cout << "\n-------------------------------------------------------";


cout << " \n Create Student Record ";
cout << "\n-------------------------------------------------------";
SetConsoleTextAttribute(hConsole, 5);
write_student();
break;
case '2':
system("cls");
SetConsoleTextAttribute(hConsole, 6);

cout << "\n-------------------------------------------------------";


cout << " \n Display Student Record ";
cout << "\n-------------------------------------------------------";

SetConsoleTextAttribute(hConsole, 5);
display_all();
break;
case '3':
system("cls");
SetConsoleTextAttribute(hConsole, 6);
Ayesha Naseer 22f-3672

cout << "\n-------------------------------------------------------";


cout << " \n Search Student Record ";
cout << "\n-------------------------------------------------------";

SetConsoleTextAttribute(hConsole, 5);
cout << "\n\n\tPlease Enter The roll number ";
cin >> num;
display_sp(num);
break;
case '4':
system("cls");
SetConsoleTextAttribute(hConsole, 6);

cout << "\n-------------------------------------------------------";


cout << " \n Modify Student Record ";
cout << "\n-------------------------------------------------------";

SetConsoleTextAttribute(hConsole, 5);
cout << "\n\n\tPlease Enter The roll number ";
cin >> num;
modify_student(num);
Ayesha Naseer 22f-3672

break;
case '5':
system("cls");
SetConsoleTextAttribute(hConsole, 6);

cout << "\n-------------------------------------------------------";


cout << " \n Delete Student Record ";
cout << "\n-------------------------------------------------------";
SetConsoleTextAttribute(hConsole, 5);
cout << "\n\n\tPlease Enter The roll number ";
cin >> num;
delete_student(num);
break;
case '6':break;
default: cout << "\a";
}
break;
case '3':
break;
default:cout << "\a";
}
Ayesha Naseer 22f-3672

} while (ch != '3');


}
else
{
cout << "\n Credentials Are Wrong.\nAccess Denied" << endl;
}
system("pause");
return 0;
}

Login page:

Main Menu:
Ayesha Naseer 22f-3672

Entry Menu:

1. Create Student Record

2. Display Student Record:


Ayesha Naseer 22f-3672

3. Search Student Record

4. Modify Student Record


Ayesha Naseer 22f-3672

Result Menu:
Ayesha Naseer 22f-3672

 Class Report

 Student Report card

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy