Intro CS Question #3 free response review. Write the following function. string
ID: 3760033 • Letter: I
Question
Intro CS Question #3 free response review.
Write the following function.
string Student::getName() {
// YOUR CODE HERE
return ""; // <--- delete this
}
int Student::getNumGrades() {
// YOUR CODE HERE
return 0; // <--- delete this
}
void Student::addGrade(int score) {
// YOUR CODE HERE - 2 lines
}
int Student::getLowestGrade() {
// YOUR CODE HERE - approximately 7 lines
return 0; // <--- delete this
}
int Student::getHighestGrade() {
// YOUR CODE HERE - very similar to getLowestGrade()
return 0; // <--- delete this
}
----------------
Link to Header.
http://pastebin.com/BHuZxmiJ
Explanation / Answer
string Student::getName() {
return name;
}
int Student::getNumGrades() {
// YOUR CODE HERE
return numGrades;
}
void Student::addGrade(int score) {
grades[numGrades] = score;
numGrades++;
}
int Student::getLowestGrade() {
int min=grades[0];
for (int i=1; i<numGrades; i++) {
if (grades[i] < min) {
min = grades[i];
}
}
return min;
}
int Student::getHighestGrade() {
int max=grades[0];
for (int i=1; i<numGrades; i++) {
if (grades[i] > max) {
max = grades[i];
}
}
return max;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.