GradeCommentByValue

GradeCommentByValue - else return "Not...

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 ; char computeGrade (int score) // We assume fixed cutoffs of 90, 80, 70, and 60. { if (score >= 90) return 'A' ; else if (score >= 80) return 'B' ; else if (score >= 70) return 'C' ; else if (score >= 60) return 'D' ; else return 'F' ; } string computeComment (int score) // We assume fixed cutoffs of 90, 80, 70, and 60. { if (score >= 90) return "Excellent work" ; else if (score >= 80) return "Good work" ; else if (score >= 70) return "Average work" ; else if (score >= 60) return "Below average work" ;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

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

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online