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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
#include <iostream>
#include <string>
using namespace std;
void studentDetails(string& nameP, string& surnameP, string& schoolNameP)
{
cout << "Enter name: ";
cin >> nameP;
cout << "Enter surname: ";
cin >> surnameP;
cout << "Enter the name of the school: ";
cin >> schoolNameP;
}
void getMarks(float& engP, float& mathP, float& life_orientP, float& histP, float& comp_litP, float& artP)
{
cout << "Enter your mark for English: ";
cin >> engP;
if (engP < 0 || engP > 100) {
do
{
cout << "Value cannot be less than 0 or greater than 100. Enter again: ";
cin >> engP;
} while (engP < 0 || engP > 100);
}
cout << "Enter your mark for Mathematics: ";
cin >> mathP;
if (mathP < 0 || mathP > 100) {
do
{
cout << "Value cannot be less than 0 or greater than 100. Enter again: ";
cin >> mathP;
} while (mathP < 0 || mathP > 100);
}
cout << "Enter your mark for Life Orientation: ";
cin >> life_orientP;
if (life_orientP < 0 || life_orientP > 100) {
do
{
cout << "Value cannot be less than 0 or greater than 100. Enter again: ";
cin >> life_orientP;
} while (life_orientP < 0 || life_orientP > 100);
}
cout << "Enter your mark for History: ";
cin >> histP;
if (histP < 0 || histP > 100) {
do
{
cout << "Value cannot be less than 0 or greater than 100. Enter again: ";
cin >> histP;
} while (histP < 0 || histP > 100);
}
cout << "Enter your mark for Computer Literacy: ";
cin >> comp_litP;
if (comp_litP < 0 || comp_litP > 100) {
do
{
cout << "Value cannot be less than 0 or greater than 100. Enter again: ";
cin >> comp_litP;
} while (comp_litP < 0 || comp_litP > 100);
}
cout << "Enter your mark for Art: ";
cin >> artP;
if (artP < 0 || artP > 100) {
do
{
cout << "Value cannot be less than 0 or greater than 100. Enter again: ";
cin >> artP;
} while (artP < 0 || artP > 100);
}
}
void awardDistinction(float& engP, float& mathP, float& life_orientP, float& histP, float& comp_litP, float& artP)
{
if ((engP + mathP + life_orientP + histP + comp_litP + artP) / 6 >= 75)
{
cout << "Passed with distinction" << endl;
}
else {
if (engP >= 75)
{
cout << "Subject distinction = English" << endl;
}
if (mathP >= 75)
{
cout << "Subject distinction = Mathematics" << endl;
}
if (life_orientP >= 75)
{
cout << "Subject distinction = Life Orientation" << endl;
}
if (histP >= 75)
{
cout << "Subject distinction = History" << endl;
}
if (comp_litP >= 75)
{
cout << "Subject distinction = Computer Literacy" << endl;
}
if (artP >= 75)
{
cout << "Subject distinction = Art" << endl;
}
}
}
void calcAverageYearMark(float& engP, float& mathP, float& life_orientP, float& histP, float& comp_litP, float& artP, float& averageP) {
averageP = (engP + mathP + life_orientP + histP + comp_litP + artP) / 6;
}
void codeSymbol(float subject, string & symbol, int& code) {
if (subject <= 29) {
symbol = "FF";
code = 1;
}
else if (subject >= 30 && subject <= 39) {
symbol = "F";
code = 2;
}
else if (subject >= 40 && subject <= 49) {
symbol = "E";
code = 3;
}
else if (subject >= 50 && subject <= 59) {
symbol = "D";
code = 4;
}
else if (subject >= 60 && subject <= 69) {
symbol = "C";
code = 5;
}
else if (subject >= 70 && subject <= 79) {
symbol = "B";
code = 6;
}
else if (subject >= 80 && subject <= 100) {
symbol = "A";
code = 7;
}
}
void display(float eng, float math, float life_orient, float hist,
float comp_lit, float art, float average, string& symbol,
int& code, string outcome, float maximum, float minimum, string name, string surname, string schoolName) {
cout << "***************************************************************************************************" << endl;
cout << "**************************************STUDENT ACADEMIC REPORT**************************************" << endl;
cout << "This program inputs the learner marks of matric level subjects and prints the students final report" << endl;
cout << "Name: " << name << " " << surname << " School: " << schoolName << endl;
cout << "Subject\tMark\tSymbol\tCode" << endl;
codeSymbol(eng, symbol, code);
cout << "English" << '\t' << eng << '\t' << symbol << '\t' << code << endl;
codeSymbol(math, symbol, code);
cout << "Mathematics" << '\t' << math << '\t' << symbol << '\t' << code << endl;
codeSymbol(average, symbol, code);
cout << "Average year mark: " << average << " with Symbol " << symbol << " and Code " << code << endl;
cout << "Outcome: " << outcome << endl;
cout << "The highest mark was " << maximum << "%" << endl;
cout << "The lowest mark was " << minimum << "%" << endl;
cout << "***************************************************************************************************" << endl;
}
int main()
{
string name, surname, schoolName, outcome;
float eng, math, life_orient, hist, comp_lit, art, average;
float maximum = 1;
float minimum = 0;
int code;
string symbol;
studentDetails(name, surname, schoolName);
getMarks(eng, math, life_orient, hist, comp_lit, art);
calcAverageYearMark(eng, math, life_orient, hist, comp_lit, art, average);
//minMax(eng, math, life_orient, hist, comp_lit, art, minimum, maximum);
//passOrFail(eng, math, life_orient, hist, comp_lit, art, outcome);
awardDistinction(eng, math, life_orient, hist, comp_lit, art);
display(eng, math, life_orient, hist, comp_lit, art, average, symbol, code, outcome, maximum, minimum, name, surname, schoolName);
return 0;
}
|