GradeCommentByValueBroken

GradeCommentByValueBroken - int main int studentScore = 0...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <cassert> using namespace std ; void computeGradeComment (int score, char grade, string comment) { if (score >= 90) { grade = 'A' ; comment = "Excellent work" ; } else if (score >= 80) { grade = 'B' ; comment = "Good work" ; } else if (score >= 70) { grade = 'C' ; comment = "Average work" ; } else if (score >= 60) { grade = 'D' ; comment = "Below average work" ; } else { grade = 'F' ; comment = "Not satisfactory" ;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } } int main() { int studentScore = 0 ; char studentGrade = 'x' ; string studentComment = "X" ; cout << "Enter the student score: " ; cin >> studentScore ; assert (cin && studentScore >= 0 && studentScore <= 100) ; computeGradeComment(studentScore, studentGrade, studentComment) ; cout << "Grade is " << studentGrade << endl ; cout << "Comment is \"" << studentComment << "\"" << endl ; return 0 ; }...
View Full Document

Ask a homework question - tutors are online