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 171 172 173
|
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#define SIZE 1
using namespace std;
int main()
{
int student, course[SIZE], course_credit[SIZE][16], course_mark[SIZE][16], counter1, counter2, counter3, counter4, counter5, i, j;
char name[SIZE][30], id[SIZE][13], matric_number[SIZE][10], course_code[SIZE][17][9];
float evaluation_point[SIZE][16], point[SIZE][16], total_point[SIZE], total_credit[SIZE], gpa[SIZE];
string grade[SIZE][16];
ofstream outdata;
for ( student = 1; student <= SIZE; student++)
{
cout << "---------------------------------------------------------------------" << endl;
cout << "\nEnter student " << student << " name :";
cin.getline(name[student], 30);
cout << "\nEnter student " << student << " id number :";
cin.getline(id[student], 13);
cout << "\nEnter student " << student << " matric number :";
cin.getline(matric_number[student], 10);
cout << "\nEnter number of course taken for student " << student << " :";
cin >> course[student];
cin.ignore();
for ( counter1 = 1; counter1 <= course[student]; counter1++)
{
cout << "\nEnter course code for course " << counter1 << " :";
cin.getline(course_code[student][counter1], 9);
cout << "\nEnter course credit for course " << counter1 << " :";
cin >> course_credit[student][counter1];
cin.ignore();
cout << "\nEnter course mark for course " << counter1 << " :";
cin >> course_mark[student][counter1];
cin.ignore();
}
for ( counter2 = 1; counter2 <= course[student]; counter2++)
{
if ( course_mark[student][counter2] >= 90 )
{
evaluation_point[student][counter2] = 4.00;
grade[student][counter2] = "A+";
}
else if ( course_mark[student][counter2] >= 80 )
{
evaluation_point[student][counter2] = 4.00;
grade[student][counter2] = "A";
}
else if ( course_mark[student][counter2] >= 75 )
{
evaluation_point[student][counter2] = 3.67;
grade[student][counter2] = "A-";
}
else if ( course_mark[student][counter2] >= 70 )
{
evaluation_point[student][counter2] = 3.33;
grade[student][counter2] = "B+";
}
else if ( course_mark[student][counter2] >= 65 )
{
evaluation_point[student][counter2] = 3.00;
grade[student][counter2] = "B";
}
else if ( course_mark[student][counter2] >= 60 )
{
evaluation_point[student][counter2] = 2.67;
grade[student][counter2] = "B-";
}
else if ( course_mark[student][counter2] >= 55 )
{
evaluation_point[student][counter2] = 2.33;
grade[student][counter2] = "C+";
}
else if ( course_mark[student][counter2] >= 50 )
{
evaluation_point[student][counter2] = 2.00;
grade[student][counter2] = "C";
}
else if ( course_mark[student][counter2] >= 45 )
{
evaluation_point[student][counter2] = 1.67;
grade[student][counter2] = "C-";
}
else if ( course_mark[student][counter2] >= 40 )
{
evaluation_point[student][counter2] = 1.33;
grade[student][counter2] = "D+";
}
else if ( course_mark[student][counter2] >= 35 )
{
evaluation_point[student][counter2] = 1.00;
grade[student][counter2] = "D";
}
else if ( course_mark[student][counter2] >= 30 )
{
evaluation_point[student][counter2] = 0.67;
grade[student][counter2] = "D-";
}
else
{
evaluation_point[student][counter2] = 0.00;
grade[student][counter2] = "E";
}
}
for ( counter3 = 1; counter3 <= course[student]; counter3++)
{
point[student][counter3] = course_credit[student][counter3] * evaluation_point[student][counter3];
}
for ( counter4 = 1; counter4 <= course[student]; counter4++)
{
total_point[student] += point[student][counter4];
total_credit[student] += course_credit[student][counter4];
}
gpa[student] = total_point[student] / total_credit[student];
}
outdata.open("studentdata.txt");
for ( i = 1; i <= SIZE; i++)
{
outdata << name[i] << endl << endl;
outdata << id[i] << endl << endl;
outdata << matric_number[i] << endl << endl;
outdata << course[i] << endl << endl;
for ( j = 1; j <= course[i]; j++)
{
outdata << course_code[i][j] << endl;
outdata << course_credit[i][j] << endl;
outdata << course_mark[i][j] << endl;
outdata << evaluation_point[i][j] << endl;
outdata << grade[i][j] << endl << endl;
}
outdata << endl << endl;
}
outdata.close();
return 0;
}
|