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
|
#include <iostream>
using namespace std;
double marks[6];
// d.A function minMax, to find and return the lowest and the highest
// of the 6 subject marks passed to it as the subject with the lowest
// mark;
int minMax(double marks[6])
{ /*Question 2d */
double max;
double min;
double minIndex;
double maxIndex;
for (int i = 0; i < 6; ++i) {
max = 0;
if (marks[i] > max) {
marks[i] = max;
maxIndex = i;
}
}
for (int i = 0; i < 6; ++i) {
min = 0;
if (marks[i] < min) {
marks[i] = min;
minIndex = i;
}
}
cout << "Your lowest mark was " << marks[minIndex] << endl;
cout << "Your highest mark is for " << marks[maxIndex] << endl;
}
// c.A function calcAverageYearMark, to calculate and display the
// average of the 6 Subjects. This function should be called just once
// by main, and should be passed the 6 Subject marks.
int calcAverageYearMark(double eng, double math, double lo, double hist, double clit, double art)
{ /*Question 2c */
double totMark;
double avgMark;
totMark = marks[0] + marks[1] + marks[2] + marks[3] + marks[4] + marks[5];
avgMark = totMark / 6;
cout << "Your averge mark is " << avgMark << endl;
}
// b. A function getMarks, that prompts the learner to key in a mark for each of the six subjects, and
// validate the marks. Do not accept marks lower than 0 or higher than 100.
int getMarks(double eng, double math, double lo, double hist, double clit, double art)
{ /*Question 2b */
cout << "Key in your mark for English: ";
cin >> eng;
cout << "Key in your mark for Mathematics: ";
cin >> math;
cout << "Key in your mark for Life Orientation: ";
cin >> lo;
cout << "Key in your mark for History: ";
cin >> hist;
cout << "Key in your mark for Computer Literacy: ";
cin >> clit;
cout << "Key in your mark for Art: ";
cin >> art;
marks[0] = eng;
marks[1] = math;
marks[2] = lo;
marks[3] = hist;
marks[4] = clit;
marks[5] = art;
}
// a. A function studentDetails, that prompts the learner to key in their personal details
// name,surname, and schoolName.
int studentDetails(string name, string school)
{ /*Question 2a */
cout << "Please key in your name: ";
cin >> name;
cout << "Please key in the name of your school: \n";
cin >> school;
/*cout << "Your weight is " << name << endl;
cout << "Your height is " << school << endl;*/
}
// e. A function passOrFail, to determine whether the student has passed or failed grade 12.
void passOrFail() // actual signature TBD
{
}
// f. A function awardDistinction to determine which of the subjects have received
// distinctions. A subject receives a distinction if the mark is 75% and above. Also a student
// has passed with distinction if the average mark is 75% and above.
void awardDistinction() // actual signature TBD
{
}
// g. A function codeSymbol, to convert each mark to a symbol (A, B, C, D, E, F) and a code
// (7,6,5,4,3,2,1). The symbol and code should be printed next to the mark in the student
// report.
// The same should be calculated and displayed for the average mark.
void codeSymbol() // actual signature TBD
{
}
// h.A function to Display the student report.
void Display() // actual signature TBD
{
}
int main()
{
string name;
string school;
double eng;
double math;
double lo;
double hist;
double clit;
double art;
studentDetails(name, school);
getMarks(eng, math, lo, hist, clit, art);
calcAverageYearMark(eng, math, lo, hist, clit, art);
minMax(marks);
return 0;
}
|