Financeit interview question

Solve this coding issue and debug problem.