GradeCommentByValueBroken

GradeCommentByValueBroken - } } int main() { int...

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 = &quot;X&quot; ; cout &lt;&lt; &quot;Enter the student score: &quot; ; cin &gt;&gt; studentScore ; assert (cin &amp;&amp; studentScore &gt;= 0 &amp;&amp; studentScore &lt;= 100) ; computeGradeComment(studentScore, studentGrade, studentComment) ; cout &lt;&lt; &quot;Grade is &quot; &lt;&lt; studentGrade &lt;&lt; endl ; cout &lt;&lt; &quot;Comment is \&quot;&quot; &lt;&lt; studentComment &lt;&lt; &quot;\&quot;&quot; &lt;&lt; endl ; return 0 ; }...
View Full Document

Ask a homework question - tutors are online