For the algorithm, you only need to know the taxation bands + corresponding rates, applicable deductions & relief values.

I have an excel sheet tucked somewhere that does the same. If this aint homework as Young Techie reckons, I can avail it later on for your peeping.