Previous Next Chapter

Grades.rexx

This program calculates the final grade for a given student based on four essay grades and a class participation grade. The average of Essay 1 and Essay 2 is worth 30%, the average of Essay 3 and Essay 4 is worth 45%, and participation is worth 25% of the final grade.

Once a final grade is displayed, an option to continue with another calculation is presented. The response is " PULLed " and if it does not equal Q (quit), the loop continues. If the response equals Q , the program quits the loop and exits.

Program 7. Grades.rexx

/*Grading program*/
SAY "Hallo, I will calculate your grades for you."
Response = 0
DO while response ~ = "Q "/*Loop while response isn't Q*/
SAY "Please enter all grades for the student."
SAY "Essay 1:"
PULL es1
SAY "Essay 2:"
PULL es2
SAY "Essay 3:"
PULL es3
SAY "Essay 4:"
PULL es4
SAY "Participation:"
PULL p
Final = (((es1 + es2)/2*.3) + ((es3 + es4)/2*.45) + (p*.25))
SAY "Your final grade for this student is " Final
SAY "Would you like to continue? (Q for quit.)"
PULL response
END
EXIT

Top Previous Next Chapter