Question 8: Acceptance tests [10]
Sometimes it is necessary to represent a number as an interval, rather than
as a fixed value, reflecting some uncertainty about the exact value. For instance,
we might use (3.134, 3.134023) to indicate that the actual value lies somewhere
with the range 3.134 to 3.134023.
If we have two positive numbers, X and Y,
each represented as intervals [Xlow, Xhigh], [Ylow, Yhigh], then
- X + Y should give [Xlow+Ylow, Xhigh+Yhigh]
- X * Y should give [Xlow*Ylow, Xhigh*Yhigh]
- X - Y should give [Xlow-Yhigh, Xhigh-Ylow], but should replace negative values with 0
- X / Y should give [Xlow/Yhigh, Xhigh/Ylow]
The program IntervalMath is supposed to allow the user to enter low and high
values for both X and Y then select one of the four operators. The program
should apply the appropriate operation and display the resulting interval.
Design an appropriate set of acceptance tests for the program,
and for each test give:
X | Y | Result |
Reason/rationale for the test |
low | high | low | high |
low | high |