Which tests expose the grade-rounding algorithm’s defect?
Use the University of Twente’s published rounding schedule (17 June 2020) as the specification, meaning the required rules, for this exercise. It converts an unrounded course result to the final grade registered in Osiris. The schedule uses n to represent the whole-number part of the unrounded result. For example, when the result is 4.62, n = 4 and n.25 means 4.25. “At least” includes the first value, while “below” excludes the second value. Registered grades are written with one decimal place.
| Case | Unrounded course result | Grade registered in Osiris |
|---|---|---|
n is not 5 |
At least n.00 and below n.25 |
n.0 |
n is not 5 |
At least n.25 and below n.75 |
n.5 |
n is not 5 |
At least n.75 and below (n + 1).00 |
(n + 1).0 |
n = 5 |
At least 5.00 and below 5.50 |
5.0 |
n = 5 |
At least 5.50 and below 6.00 |
6.0 |
The table is the specification. Use it to obtain the expected grade, then trace the proposed algorithm to obtain the actual grade.
Input: Unrounded Result
Output: Osiris Grade
Start
Set n to the whole-number part of Unrounded Result
Set Decimal Part to Unrounded Result - n
If Decimal Part < 0.25
Set Osiris Grade to n
Else If Decimal Part < 0.75
Set Osiris Grade to n + 0.5
Else
Set Osiris Grade to n + 1
End If
Output Osiris Grade
EndEach input -> expected output below describes one test. All listed expected outputs follow the schedule. A test fails when the actual and expected grades differ. Which option contains two failing tests?
- Test
5.24 -> 5.0and test5.25 -> 5.0. - Test
5.00 -> 5.0and test5.99 -> 6.0. - Test
5.49 -> 5.0and test5.50 -> 6.0. - Test
5.74 -> 6.0and test5.75 -> 6.0.