American Express Interview Question

They asked a java program to reverse the function.