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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
void studentDetails ( string &name, string &surname, string &schoolName)
{
cout << "Enter the students name: " << endl;
cin >> name;
cout << "Enter the students surname: " << endl;
cin >> surname;
cout << "Enter the students school: " << endl;
cin >> schoolName;
}
void checkMark(float m)
{
if (m >100 && m < 0)
{
cout << "ERROR - Invalid input";
}
else
cout << "Thank you, mark is valid." << endl;
}
void getMarks(float & Engmark, float & Mathmark, float & LOmark, float & Hismark, float & CompLmark, float & Artmark)
//These are the literal values as per the user input
{
cout << "Enter a mark for English: " << endl;
cin >> Engmark;
checkMark(Engmark);
cout << "Enter a mark for Mathematics: " << endl;
cin >> Mathmark;
checkMark(Mathmark);
cout << "Enter a mark for Life Orientation: " << endl;
cin >> LOmark;
checkMark(LOmark);
cout << "Enter a mark for History: " << endl;
cin >> Hismark;
checkMark(Hismark);
cout << "Enter a mark for Computer Literacy: " << endl;
cin >> CompLmark;
checkMark(CompLmark);
cout << "Enter a mark for Art: " << endl;
cin >> Artmark;
checkMark(Artmark);
}
void calcAverageYearMark(float a, float b, float c, float d, float e, float f)
//These are variables that get passed the true values from EngMark, Mathmark, etc. . .
{
float calcAve = (a + b + c + d + e + f)/6;
// calculate average of the input values
cout << "Average Year Mark: " << calcAve;
}
void minMax(float &Engmark, float &Mathmark, float LOmark, float Hismark, float CompLmark, float Artmark)
{
float largest = 0;
float smallest = 100;
if (Engmark < smallest)
{
smallest = Engmark;
}
else if (Engmark > largest)
{
largest = Engmark;
}
if (Mathmark < smallest)
{
smallest = Mathmark;
}
else if (Mathmark> largest)
{
largest = Mathmark;
}
if (LOmark < smallest)
{
smallest = LOmark;
}
else if (LOmark> largest)
{
largest = LOmark;
}
if (Hismark < smallest)
{
smallest = Hismark;
}
else if (Hismark> largest)
{
largest = Hismark;
}
if (CompLmark < smallest)
{
smallest = CompLmark;
}
else if (CompLmark > largest)
{
largest = CompLmark;
}
if (Artmark < smallest)
{
smallest = Artmark;
}
else if (Artmark > largest)
{
largest = Artmark;
}
cout << "The highest mark was " << largest << endl;
cout << "The smallest mark was " << smallest << endl;
}
void passOrFail(float &Engmark, float &Mathmark, float &LOmark, float &Hismark, float &CompLmark, float &Artmark)
{
bool passed = true;
if (Engmark < 50)
{
passed = false;
}
else if(Engmark >= 50 && Mathmark >= 50 && LOmark >=50 && Hismark >=50 && Artmark >= 50)
{
passed = true;
}
else if(Engmark >= 50 && Mathmark >= 50 && LOmark >=50 && Artmark >=50 && CompLmark <= 50)
{
passed = true;
}
else // none of above criteria worked
{
passed = false;
// statement of pass based on value of passed variable
if (passed = true)
{
cout << "Outcome: Passed" << endl;
}
else (passed = false)
{
cout << "Outcome: Failed" << endl;
}
}
}
void awardDistinction(float &Engmark, float &Mathmark, float &LOmark, float &Hismark, float &CompLmark, float &Artmark)
{
float disct = 75;
if (Engmark >= disct || Mathmark >= disct || LOmark >= disct || Hismark >= disct || CompLmark >= disct || Artmark >= disct )
{
cout << "You have a subject distinction"
}
float calcAve = (EngMark + Mathmark + LOmark + Hismark + CompLmark + Artmark)/ 6;
// calculate average of the input values
if (calcAve >= 75)
{
cout << "Congrats, you have year distinction";
}
}
void codeSymbol(float m)
{
if(m <=100 && m >= 80)
{
cout << "A\t" << "7" << endl;
}
else if(m <= 79 && m >= 70)
{
cout << "B\t" << "6" << endl;
}
else if (m <= 69 && m >= 60)
{
cout << "C\t" << "5" << endl;
}
else if (m <= 59 && m >= 50)
{
cout << "D\t" << "4" << endl;
}
else if (m <= 49 && m >= 40)
{
cout << "E\t" << "3" << endl;
}
else if (m <= 39 && m >= 30)
{
cout << "F\t" << "2" << endl;
}
else if (m <= 29 && m >= 0)
{
cout << "FF\t" << "1" << endl;
}
}
void displayReport(string name, string surname, string schoolName, float Engmark, float Mathmark, float LOmark, float Hismark, float CompLmark, float Artmark)
{
cout << "****************************************************" << endl;
cout << "\t\t\t STUDENT ACADEMIC RECORD" << endl;
cout << "This program inputs the learner marks of matric level" << endl;
cout << "subjects and prints the student final report." << endl;
cout << "****************************************************************" << endl;
cout << "NAME: " << name << " " << surname << "\tSCHOOL: " << schoolName << endl;
cout << "Subject:\t\tMark:\tSymbol:\tCode:"<< endl;
cout << "English\t" << Engmark << "%\t" << codeSymbol(Engmark) << endl;
cout << "Maths\t" << Mathmark << "%\t" << codeSymbol(Mathmark) << endl;
cout << "Life Orientation\t" << LOmark << "%\t" << codeSymbol(LOmark) << endl;
cout << "History\t" << Hismark << "%\t" << codeSymbol(Hismark) << endl;
cout << "Computer Literacy\t" << CompLmark << "%\t" << codeSymbol(CompLmark) << endl;
cout << "Art\t" << Artmark << "%\t" << codeSymbol(Artmark) << endl;
}
int main()
{
string name, surname, schoolName;
float Engmark, Mathmark, LOmark, Hismark, CompLmark, Artmark;
calcAverageYearMark(Engmark, Mathmark, LOmark, Hismark, CompLmark, Artmark)
// Pass the real values to the function
studentDetails(name,surname,schoolName)
displayReport(name, surname, schoolName, Engmark, Mathmark, LOmark, Hismark, CompLmark, Artmark);
passOrFail(Engmark, Mathmark, LOmark, Hismark, CompLmark, Artmark)
awardDistinction(Engmark, Mathmark, LOmark, Hismark, CompLmark, Artmark)
minMax(Engmark, Mathmark, LOmark, Hismark, CompLmark, Artmark)
return 0;
| |