Implemented Exercise 8 using interrupt.