q4)write a function called letter grade that has a type int parameter called points and returns the appropriate letter grade using a straight scale ( 90-100 is an A,80-89is a B and so on )
1
Expert's answer
2013-05-08T09:50:14-0400
#include<iostream> /* write a function called letter grade that has a type int parameter called points and returns the appropriate letter grade using a straight scale ( 90-100 is an A,80-89is a B and so on ) */
char letter_grade(int points) { // change points to be in the range 0..100 if it is not. // thus if points<0, then return letter 'A'+10='K' // and if point > 100, then return letter 'A' if (points<=0) return 'A'+10; if (points>=100) return 'A'; char& pt = (char) points; // Now pt is in the range 0..99 and the grade is determined // by the first digit of pt, which can be computed as pt/10. // We need that if& pt/10 == 9, then the grade must be 'A'. // Therefore the grade must be computed by the following formula: char grade = 'A' + 9 - (pt/10); return grade; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment