write a value-returning function to do each of the following.Write a main progra
ID: 3614850 • Letter: W
Question
write a value-returning function to do each of the following.Write a main program that tests each function, using appriopriateparameters; output the results of each function call to file.
1) The function has a parameter giving the percent correct on atest. It returns the letter grade(using the usual scale).
2) The function returns the message "you win!" if two integervalues are equal. The function returns the message "close!" if thetwo integer values differ by 10 or less. If the difference ismorethan 10, the message returned is "Try again".
Explanation / Answer
#include #include using namespace std; char getGrade(int percentCorrect) { if(percentCorrect >=90) return 'A'; else if( (percentCorrect >=80) &&(percentCorrect < 90)) return 'B'; else if( (percentCorrect >=80) &&(percentCorrect < 90)) return 'B'; else if( (percentCorrect >=70) &&(percentCorrect < 80)) return 'C'; else if( (percentCorrect >=60) &&(percentCorrect < 70)) return 'D'; else return 'F'; } string message(int a, int b) { if(a == b) return "You Win!"; else if(((a-b) * (a-b))Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.