-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
103 lines (84 loc) · 1.74 KB
/
test.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
102
103
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
int main()
{
int n = 5; // number of students that entered the university in that day
int m = 4; // columns
vector<vector<string>> database(n+1, vector<string>(m));
vector<vector<string>> banner_db(n+1, vector<string>(m));
ifstream students;
ofstream banner;
banner.open("rewards_fines.txt");
students.open("students.txt");
if (students.fail())
{
cout << "*** ERROR: Cannot open " << "students.txt" << endl;
// failure return
} // end if
if (banner.fail())
{
cout << "*** ERROR: Cannot open " << "rewards/fines.txt" << endl;
// failure return
} // end if
//students.ignore(61);
for (int i = 0; i < n+1; i++)
{
for (int j = 0; j < m; j++)
{
students >> database[i][j];
}
}
for (int i = 0; i < n+1; i++)
{
for (int j = 0; j < m; j++)
{
cout<< database[i][j]<<" ";
}
cout << endl;
}
banner_db = database;
banner_db[0][2] = "Fines";
banner_db[0][3] = "Rewards";
for (int i = 1; i < n+1; i++)
{
if (database[i][2] == "1")
{
banner_db[i][2] = "warning";
}
if (database[i][2] == "2")
{
banner_db[i][2] = "50 egp";
}
if (database[i][2] == "3")
{
banner_db[i][2] = "100 egp";
}
if (database[i][2] == "4")
{
banner_db[i][2] = "200 egp";
}
}
for (int i = 1; i < n+1; i++)
{
if (database[i][3] == "10")
{
banner_db[i][3] = "50egp voucher";
}
if (database[i][3] == "20")
{
banner_db[i][3] = "100egp voucher";
}
}
for (int i = 0; i < n+1; i++)
{
for (int j = 0; j < m; j++)
{
banner<< banner_db[i][j]<<" ";
}
banner << "\n";
}
return 0;
}