198k views
4 votes
Define a function ScaleGrade that takes two parameters: • points: an integer, passed by value, for the student's score. • grade: a char, passed by reference, for the student's letter grade. ScaleGrade() changes grade to C if the points are greater than or equal to 67 and less than 80, and grade is not C. Otherwise, grade is not changed. The function returns true if grade has changed, and returns false otherwise. Ex: If the input is 67 D, then the output is: Grade is C after curving. 2 using namespace std; 3 4 int main() { 5 int studentTotal; 6 char studentGrade; 7 bool isChanged; 8 9 cin >> student Total; 10 cin >> studentGrade; 11 12 isChanged = ScaleGrade (studentTotal, studentGrade); 13 14 if (isChanged) { 15 cout << "Grade is " << studentGrade << " after curving." endl; 16 } 17 else { 18 cout << "Grade " << studentGrade << " is not changed." << endl; 19 } 20 1 2 3

1 Answer

6 votes

Answer:

C++ code:

bool ScaleGrade(int points, char& grade) {

if (points >= 67 && points < 80 && grade != 'C') {

grade = 'C';

return true;

}

return false;

}

Step-by-step explanation:

Step-by-step explanation:

- The function is defined with two parameters, an integer `points` and a character `grade`, passed by reference.

- The function first checks if `points` is within the range of 67 to 79, and if `grade` is not already 'C'.

- If the condition is true, the function assigns 'C' to `grade` and returns true.

- If the condition is false, the function returns false without changing `grade`.

User Ecoologic
by
8.1k points