I need to create a new number based on conditional findings of the original number, using 3 sets of criteria as follows:

If a number (no decimals) ends with:

a) 0, 9, 8 or 1 = the new number ends with 8

b) 2 or 3 = the new number ends with 3

c) 4, 5, 6, or 7 = the new number ends with 7

For Example:

400 new number = 408

312 new number = 313

544 new number = 547

Please help, I very much appreciate it!!

Thanks kindly, Dale