-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
177 lines (126 loc) · 4.6 KB
/
Copy pathmain.cpp
File metadata and controls
177 lines (126 loc) · 4.6 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <stdlib.h>
using namespace std;
int * hozoorghiab(int arr[], int counter, string info[]);
int main() {
cout << "Hello! Welcome to the console software that you can use to record your students' grades and presence in class! The final form is shown on your output screen when you've recorded all the info. it is also held in a text file named \"finalform.txt\". the default text file you need to run this program in included in a" <<" text file named \"CPP.4001.CE\". the final grade equals the project grade and the final exam grade combined (20 is the best score you can get)." << endl << endl;
// read the user main file, containing the students' names, codes and the number of classes held in total
ifstream reader("CPP.4001.CE.QIAU.txt");
ofstream final("finalform.txt");
// the number of classes held is stored is classcount
int classcount = 0;
reader >> classcount;
// see how many students there are, held in studentcount
int shomar = 0;
while (reader) {
string hello;
reader >> hello;
shomar++;
}
int studentcount = (shomar - 1) / 4;
cout << "there are " << studentcount << " students in class and" << classcount << " classes will be held" << endl << endl;
// store the student id in an array
string fillin;
reader.clear();
reader.seekg(0);
reader >> fillin;
string stdid[studentcount];
string aidi;
for (int i = 0; i < studentcount; i++) {
for (int c = 0; c < 4; c++) {
string temp;
reader >> temp;
aidi = aidi + " " + temp;
}
stdid[i] = aidi;
aidi = "";
}
//prompt the user for each day and store the results in an array
reader.clear();
reader.seekg(0);
int arr[studentcount];
int *hozoorlist;
int fullabpresent;
fullabpresent = classcount * studentcount;
int fullhozoorlist[fullabpresent];
int listcounter = 0;
cout << "record your students' presence in class!" << endl <<endl;
for (int day = 0; day < classcount; day++) {
cout << endl << "day" << day + 1 << endl;
hozoorlist = hozoorghiab(arr, studentcount, stdid);
for (int i = 0; i < studentcount; i++) {
fullhozoorlist[listcounter] = hozoorlist[i];
listcounter++;
}
}
// store the project grades in an array
int projectlist[studentcount];
int projectgrade;
for (int i = 0; i < studentcount; i++)
{
do
{
cout << "enter student" << stdid[i] << "'s" << " project grade (must be between 0 and 10)" << endl << endl;
cin >> projectgrade;
projectlist[i] = projectgrade;
} while (projectgrade > 10 || projectgrade < 0);
}
// store the final exam grade in an array
int examlist[studentcount];
int examgrade;
for (int i = 0; i < studentcount; i++)
{
do
{
cout << "enter student" << stdid[i] << "'s" << " exam grade (must be between 0 and 10)" << endl << endl;
cin >> examgrade;
examlist[i] = examgrade;
} while (examgrade > 10 || examgrade < 0);
}
// put the full information in front of the id
cout << "the class is completed!" << endl;
int adad = 0;
for (int x = 0; x < studentcount; x++)
{
cout << stdid[x];
for (int c = 0; c < classcount; c++)
{
int holder = c * studentcount + x;
cout << " " << fullhozoorlist[holder] << " ";
}
cout << " " << projectlist[x] << " " << examlist[x] << " " << projectlist[x] + examlist[x];
cout << endl;
}
// store the data in file
for (int x = 0; x < studentcount; x++)
{
final << stdid[x];
for (int c = 0; c < classcount; c++)
{
int holder = c * studentcount + x;
final << " " << fullhozoorlist[holder] << " ";
}
final << " " << projectlist[x] << " " << examlist[x] << " " << projectlist[x] + examlist[x];
final << "\n";
}
reader.close();
final.close();
}
int * hozoorghiab(int arr[], int counter, string info[])
{
// prompt the user to fill in the list by typing 1 for present and 0 for absent
for (int i = 0; i < counter; i++)
{
do {
cout << endl << "press 1 for present and 0 for absent for" << info[i] << "'s "
<< "condition in today's class" << endl;
int give;
cin >> arr[i];
}
while (arr[i] != 1 && arr[i] != 0);
}
return arr;
}