RBC interview question

Write a code and test its use cases and fix it