Consolidate duplicate code for calculating tax and tip