Generate Loan EMI Schedule With Paise-Accurate Final Installment

Last updated: November 29, 2026

Quick Overview

Given a loan principal, an annual interest rate and a tenure in months, compute the monthly EMI and an amortization schedule where each row splits the payment into interest and principal, rounding to two decimals and adjusting the last installment so the balance ends at exactly zero.

TCS
Coding & Algorithms
Software Engineer
TCS
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a loan principal, an annual interest rate and a tenure in months, compute the monthly EMI and an amortization schedule where each row splits the payment into interest and principal, rounding to two decimals and adjusting the last installment so the balance ends at exactly zero.

Lending modules in TCS BaNCS and the bank projects TCS delivers depend on amortization math that matches to the paise. A technical interviewer uses this to check formula knowledge, money handling with Decimal instead of float, and the rounding drift that shows up in the final row.

What the Interviewer Expects
  • State the EMI formula and the zero-interest special case
  • Use Decimal (or integer paise) instead of float for money
  • Round interest each month and carry the real balance forward
  • Absorb rounding drift in the last installment
  • Explain why the schedule must reconcile to the principal
Key Topics to Cover
Amortization
Decimal arithmetic
Rounding
Financial correctness
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would a part-prepayment in month 6 change the schedule (reduce EMI vs reduce tenure)?
  • How do you handle a rate change mid-tenure on a floating-rate loan?
  • Why does float arithmetic fail an audit here?
  • How would you test this against a bank's published schedule?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Monthly rate i=r/1200i = r/1200. EMI =P⋅i(1+i)n/((1+i)n−1)= P \cdot i (1+i)^n / ((1+i)^n - 1), or P/nP/n when i=0i = 0. Each month: interest == round(balance ×i\times i), principal part == EMI −- interest, balance reduces b...

High-Level Design

Compute the rounded EMI once, then iterate months. Because both EMI and monthly interest are rounded, the last month's balance drifts by a few paise, so the final installment is defined as remaining b...


Submit Your Answer
Markdown supported

Related Questions