-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mark.cpp
101 lines (97 loc) · 2.71 KB
/
Mark.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
#include "Mark.h"
#include "Tab.h"
#include <fstream>
#include <string>
using namespace std;
void Mark::getMarkDetails()
{
cout << "\n\t\tEnter Student ID: ";
cin >> this->studentId;
cout << "\n\t\tEnter Student's mark: ";
cin >> this->mark;
cout << "\n\t\tEnter Course code: ";
cin >> this->courseCode;
storeMember();
cout << "\n\t\tYou successfully graded the student!";
}
// SHOW THE STUDENT DATA FUNCTION
void Mark::showMemberData()
{
cout << this->studentId << " \t\t" << this->mark << "\t\t" << this->courseCode << endl
<< endl;
}
// SAVE THE MARKS DATA IN MARKS.DAT FILE FUNCTION
void Mark::storeMember()
{
ofstream fout;
fout.open("marks.dat", ios::app | ios::binary);
fout.write((char *)&studentId, sizeof(int));
fout.write((char *)&mark, sizeof(string));
fout.write((char *)&courseCode, sizeof(string));
fout.close();
}
// DISPLAYING MARKS IN PROFESSOR TAB
void Mark::showMarksProf(string &coursecode)
{
int counter = 0;
ifstream fin;
fin.open("marks.dat", ios::in | ios::binary);
if (!fin)
cout << "\nFile not found";
else
{
fin.read((char *)&studentId, sizeof(int));
fin.read((char *)&mark, sizeof(string));
fin.read((char *)&courseCode, sizeof(string));
while (!fin.eof())
{
if (coursecode == courseCode)
{
showMemberData();
counter++;
}
fin.read((char *)&studentId, sizeof(int));
fin.read((char *)&mark, sizeof(string));
fin.read((char *)&courseCode, sizeof(string));
}
if (counter == 0)
cout << "\t\tCourse code not found\n\n";
fin.close();
}
}
// DISPLAY THE MARKS OF A STUDENT DATA FUNCTION
void Mark::displayStData()
{
cout << this->mark << "\t\t" << this->courseCode << "\t\t" << this->studentId << endl
<< endl;
}
// DISPLAY MARKS OF A STUDENT
void Mark::displayMarksStud(int &iD)
{
int counter = 0;
ifstream fin;
fin.open("marks.dat", ios::in | ios::binary);
if (!fin)
cout << "\nFile not found";
else
{
fin.read((char *)&studentId, sizeof(int));
fin.read((char *)&mark, sizeof(string));
fin.read((char *)&courseCode, sizeof(string));
while (!fin.eof())
{
if (iD == studentId)
{
displayStData();
counter++;
}
fin.read((char *)&studentId, sizeof(int));
fin.read((char *)&mark, sizeof(string));
fin.read((char *)&courseCode, sizeof(string));
}
if (counter == 0)
cout << "\t\t Marks are not found\n\n";
fin.close();
}
}