0% found this document useful (0 votes)
13 views17 pages

Microfinance Loan Management System

The document outlines the design and implementation of a Java console application for a Microfinance system, covering aspects like customer management, loan products, and repayment schedules. It specifies class requirements, business rules, and console interface requirements, while also providing a UML class diagram and source code for various classes such as Customer, Loan, and Repayment. The application aims to demonstrate object-oriented principles and ensure accurate loan management functionalities.

Uploaded by

r.thenmozli222
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views17 pages

Microfinance Loan Management System

The document outlines the design and implementation of a Java console application for a Microfinance system, covering aspects like customer management, loan products, and repayment schedules. It specifies class requirements, business rules, and console interface requirements, while also providing a UML class diagram and source code for various classes such as Customer, Loan, and Repayment. The application aims to demonstrate object-oriented principles and ensure accurate loan management functionalities.

Uploaded by

r.thenmozli222
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Question:

25) Microfinance Loans & Repayments


Problem Statement:
Design and implement a Java console application for a Microfinance system that
manages customers, loan products, loans, disbursements, EMIs, repayments, and
penalties. The application should demonstrate object-oriented principles and ensure
accurate schedules and balances.
Class Requirements:
1. Customer
2. LoanProduct
3. Loan
4. Disbursement
5. RepaymentSchedule
6. Repayment
7. Penalty
Business Rules:
1. Loan eligibility must be verified before approval.
2. Disbursement activates the repayment schedule immediately.
3. Repayments reduce outstanding principal and interest as per schedule.
4. Late or partial payments may trigger penalties.
5. Each repayment must link to a loan and scheduled installment.
Console Interface Requirements:
1. Menu-driven program: Add Customer / Add Loan Product / Approve Loan /
Disburse Loan / Generate Schedule / Record Repayment / View Outstanding /
Exit
2. Input validations must be performed for all user entries.
3. Encapsulation must be followed for all attributes.
Expected Output Behavior:
• Show amortization schedule and current outstanding.
• Show repayment receipt with principal/interest split and penalties (if any).
• Show loan status (active/closed/in arrears).
Questions for Students:
1. Draw the UML Class Diagram for the above system.
2. Implement the Classes with necessary Data Members and Methods for System
and Business Rules.
3. Use Aggregation, Inheritance and Polymorphism wherever required.
4. Implement the main method for Menu Driven System.

UML diagram:

Customer
- customerId: String
- name: String
- address: String
-phone: String
-loans : Loan
+ Customer (customerId: String, name: String, address: String, phone:String)
+ isEligible (loan: Loan): Boolean
+ addLoan (loan: Loan): void
+ updateDetails (): void

LoanProduct
- productId: String
- productName: String
- interestRate: double
- tenureMonths: int
+ LoanProduct (productId: String, productName: String interestRate:
double, , tenureMonths: int)
+ calculateEMI(principal: double, tenure: int): double
+ validateAmount(amount: double): boolean
Loan
- loanId: String
- customer: Customer
- loanProduct: LoanProduct
- principal: double
- status: String
+Loan(loanId: String, customer: Customer, loanProduct: LoanProduct,
principal: double, interestRate: double, tenureMonths: int)
+ approveLoan(): boolean
+ disburseLoan(): void
+ generateSchedule(): void
+ recordRepayment(amount: double): void

RepaymentSchedule
- loan: Loan
- totalEMI: double
- remainingBalance: double

+ RepaymentSchedule(loan: Loan)
+ showSchedule(): void

Repayment
- amountPaid: double
- paymentDate: Date
+ Repayment(amount: double, date: Date)
+ processRepayment(): void

Abstract: Penalty
- amount: double
- reason: String
+ Penalty(amount: double, reason: String)
+ applyPenalty(): void
RELATIONSHIP:

CLASS RELATIONSHIP CLASS


Customer has-a Loan
Loan has-a LoanProduct
Loan has-a Disbursement
Loan has-a RepaymentSchedule
RepaymentSchedule has-a Repayment
Penalty is-a LatePaymentPenalty and
PartialPaymentPenalty
Loan has-a Penalty

SOURCE CODE:
[Link]
package javaassignment2;

import [Link];
import [Link];

public class Customer {

private String customerId;


private String name;
private String address;
private String phone;
private List<Loan> loans;

public Customer(String customerId, String name, String address, String phone) {


[Link] = customerId;
[Link] = name;
[Link]=address;
[Link]=phone;
loans = new ArrayList<>();
}

public boolean isEligible(Loan loan) {


return [Link]() <= 150000;
}

public void addLoan(Loan loan) {


[Link](loan);
[Link]("loan added for customer:"+name);
}

public void updateDetails() {


[Link]("customer details updated");
}

public String getCustomerId() {


return customerId;
}
public String getName() {
return name;
}
public List<Loan> getLoans() {
return loans;
}

public String getAddress() {


return address;
}

public void setAddress(String address) {


[Link] = address;
}

public String getPhone() {


return phone;
}

public void setPhone(String phone) {


[Link] = phone;
}
}

[Link]
package javaassignment2;

import [Link];

public class Disbursement {

private double amount;


private Date date;

public Disbursement(double amount, Date date) {


[Link] = amount;
[Link] = date;
}

public void recordDisbursement() {


[Link]("Disbursement of rs." + amount + "recorded on" + date);
}

public double getAmount() {


return amount;
}
public Date getDate() {
return date;
}
}
[Link]

package javaassignment2;

import [Link];

public class Loan {


private String loanId;
private Customer customer;
private LoanProduct loanProduct;
private double principal;
private String status;
private RepaymentSchedule schedule;
private Disbursement disbursement;

public Loan(String loanId, Customer customer, LoanProduct loanProduct, double principal) {


[Link] = loanId;
[Link] = customer;
[Link] = loanProduct;
[Link] = principal;
[Link] = "pending";
}

public boolean approveLoan() {


if ([Link](this)) {
[Link] = "Approved";
[Link]("Loan id:"+[Link]+"approved");
return true;
} else {
[Link]("Loan not approved for"+[Link]);
return false;
}
}

public void disburseLoan() {


if ([Link]("Approved")) {
status = "Active";
disbursement = new Disbursement(principal, new Date());
[Link]();
schedule = new RepaymentSchedule(this);
[Link]("Loan disbursed");
} else {
[Link]("Loan not approved for disbursement");
}
}

public void generateSchedule() {


if (schedule != null) {
[Link]();
} else {
[Link]("No schedule available");
}
}

public void recordRepayment(double amount) {


if (schedule != null) {
Repayment repayment = new Repayment(amount, new Date());
[Link]();
[Link](amount);
} else {
[Link]("No schedule to record repayment");
}
}

public double getPrincipal() {


return principal;
}
public LoanProduct getLoanProduct() {
return loanProduct;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
[Link] = status;
}
public String getLoanId() {
return loanId;
}
public Customer getCustomer() {
return customer;
}
public RepaymentSchedule getSchedule() {
return schedule;
}
}

[Link]
package javaassignment2;

public class LoanProduct {

private String productId;


private String productName;
private double interestRate;
private int tenureMonths;
public LoanProduct(String productId, String productName, double interestRate, int tenureMonths) {
[Link] = productId;
[Link] = productName;
[Link] = interestRate;
[Link] = tenureMonths;
}

public double calculateEMI(double principal, int tenure) {


double r = interestRate/(12*100);
return (principal*r*[Link](1 + r, tenure))/([Link](1 + r, tenure)-1);
}

public boolean validateAmount(double amount) {


if(amount > 0 && amount <= 150000)
{
return true;
}
else {
return false;
}
}

public String getProductId() {


return productId;
}
public int getTenureMonths() {
return tenureMonths;
}
public double getInterestRate() {
return interestRate;
}
public String getProductName() {
return productName;
}

[Link]

package javaassignment2;

import [Link];
import [Link];

public class Repayment {

private double amountpaid;


private Date paymentdate;
public Repayment(double amountpaid, Date paymentdate) {
[Link] = amountpaid;
[Link] = paymentdate;
}

public void processRepayment() {


[Link]("Repayment of rs." + [Link] + " processed on " + new
SimpleDateFormat("dd-MM-yyyy").format(paymentdate));
}

public double getAmountPaid() {


return amountpaid; }
public Date getPaymentDate() {
return paymentdate; }
}

[Link]
package javaassignment2;

public class RepaymentSchedule {

private Loan loan;


private double totalEMI;
private double remainingBalance;

public RepaymentSchedule(Loan loan) {


[Link] = loan;
[Link] = [Link]().calculateEMI([Link](),
[Link]().getTenureMonths());
[Link] = [Link]();
}

public void showSchedule() {


[Link]("Loan Schedule:");
[Link](" ");
[Link]("Loan ID:"+[Link]());
[Link]("monthly EMI:rs." + [Link]("%.2f", totalEMI));
[Link]("Remaining balance: rs." + [Link]("%.2f", remainingBalance));
[Link]("Status: "+ [Link]());
}

public void updateBalance(double amount) {


remainingBalance -= amount;
[Link]("Balance updated remaining:rs." +[Link]);
if (remainingBalance <= 0) {
[Link]("Loan fully repaid");
[Link]("Closed");
}
}

public void updatebalance(double amount) {


remainingBalance += amount;
[Link]("Balance updated remaining:rs." +[Link]);
if (remainingBalance <= 0) {
[Link]("Loan fully repaid");
[Link]("Closed");
}
}

public double getRemainingBalance() {


return remainingBalance; }
public double getTotalEMI() {
return totalEMI; }

[Link]
package javaassignment2;

public abstract class Penalty {

protected double amount;


protected String reason;

public Penalty(double amount, String reason) {


[Link] = amount;
[Link] = reason;
}

public abstract void applyPenalty();

public double getAmount() {


return amount; }
public String getReason() {
return reason; }
}

[Link]

package javaassignment2;

class LatePaymentPenalty extends Penalty {

public LatePaymentPenalty(double amount, String reason) {


super(amount, reason);
}

@Override
public void applyPenalty() {
[Link]("Late payment penalty applied:rs." + amount + "reason:"+ reason);
}
}

[Link]

package javaassignment2;

class PartialPaymentPenalty extends Penalty {

public PartialPaymentPenalty(double amount, String reason) {

super(amount, reason);
}

@Override
public void applyPenalty() {

[Link]("Partial Payment Penalty Applied: Rs." + amount + "reason:" + reason);


}
}

[Link]
package javaassignment2;

import [Link].*;

public class Testloan {

public static void main(String[] args) {

Scanner sc = new Scanner([Link]);


List<Customer> customers = new ArrayList<Customer>();
List<LoanProduct> products = new ArrayList<LoanProduct>();
List<Loan> loans = new ArrayList<Loan>();

int ch;

Customer c1 = new Customer("acc1", "Karthikeyan", "Coimbatore", "7806821770");

[Link](c1);

LoanProduct lp1 = new LoanProduct("LP771", "Home Loan", 12.0, 24);


[Link](lp1);

Loan l1 = new Loan("L001", c1, lp1, 500000);

[Link](l1);

[Link](l1);

while(true)
{
[Link]("[Link] customer [Link] product [Link] loan [Link] [Link]
[Link] [Link] [Link] penalty [Link]");

[Link]("Enter choice:");
ch = [Link]();

switch (ch) {
case 1:
{
String cusid = "CNRB78" + ([Link]() + 1);
[Link]();
[Link]("name: ");
String name = [Link]();
[Link]("address: ");
String address = [Link]();
[Link]("phone: ");
String phone = [Link]();

[Link](new Customer(cusid, name, address, phone));


[Link]("customer added");
break;
}

case 2:
{
[Link]("product id:");
[Link]();
String proid = [Link]();
[Link]("name: ");
String proname = [Link]();
[Link]("interest: ");
double rate = [Link]();
[Link]("tenure: ");
int tenure = [Link]();
[Link](new LoanProduct(proid, proname, rate, tenure));
[Link]("Product added");
break;
}

case 3:
{
if ([Link]() || [Link]()) {
[Link]("there is no customer");
break;
}
for (int i = 0; i < [Link](); i++)
[Link]((i+1) +":"+ [Link](i).getName());
[Link]("Select customer:");
int cusno = [Link]();

for (int i = 0; i < [Link](); i++)


[Link]((i+1) + ":" + [Link](i).getProductName());
[Link]("Select product:");
int prono = [Link]();

[Link]("amount:");
double money = [Link]();

Loan loan = new Loan("CNRBL" + ([Link]() + 1), [Link](cusno - 1),


[Link](prono - 1), money);
if ([Link]())
{
[Link](loan);
[Link](cusno - 1).addLoan(loan);
}
break;}

case 4:
{
for (Loan l : loans)
if ([Link]().equals("Approved"))
{
[Link]();
}
break;
}

case 5:
{
for (int i = 0; i < [Link](); i++)
[Link]((i+1) + ":" + [Link](i).getLoanId());
[Link]("Select:");
int sno = [Link]();
[Link](sno-1).generateSchedule();
break;
}

case 6:
{
for (int i = 0; i < [Link](); i++)
{
if ([Link](i).getStatus().equals("Active"))
[Link]((i+1) + ". " + [Link](i).getLoanId());}
[Link]("select:");
int lno = [Link]();
[Link]("amount: ");
double pay = [Link]();
[Link](lno - 1).recordRepayment(pay);
break;
}
case 7:
{
if ([Link]()) {
[Link]("no customers");}

[Link]("Customers:");
for (int i = 0; i < [Link](); i++)
{
[Link]((i + 1) + ". " + [Link](i).getName());}

[Link]("Selectcustomer: ");
int csel = [Link]();

Customer cust = [Link](csel-1);


if ([Link]().isEmpty()) {
[Link]("No loans for" + [Link]());
break;
}

[Link]("Loans:");

for (int i = 0; i < [Link]().size(); i++)


[Link]((i + 1) + ". " + [Link]().get(i).getLoanId());

[Link]("Select loan:");
int lsel = [Link]();

Loan ln = [Link]().get(lsel - 1);


if ([Link]() != null)
[Link]("Remaining: Rs." + [Link]().getRemainingBalance());
else
[Link]("No schedule generated yet!");

break;
}

case 8:
{
if ([Link]()) {
[Link]("No loans available!");
break;
}

[Link]("Loans:");
for (int i = 0; i < [Link](); i++) {
Loan l = [Link](i);
[Link]((i + 1) + ":" + [Link]() + " " + [Link]().getName());
}

[Link]("Select loan to apply penalty: ");


int lsel = [Link]();

Loan loan = [Link](lsel - 1);

[Link]("[Link] payment [Link] payment");


[Link]("Choose type:");
int type = [Link]();

[Link]("Enter penalty amount: ");


double amount = [Link]();

[Link]("Enter reason:");
String reason = [Link]();

Penalty p;
if (type == 1)
p = new LatePaymentPenalty(amount, reason);
else
p = new PartialPaymentPenalty(amount, reason);

[Link]();
if ([Link]() != null)

[Link]().updatebalance(amount);

[Link]("Penalty added to loan" + [Link]());


break;
}

case 9:
[Link]("Exit");
return;

default:
[Link]("Invalid!");
}
}

}
}

OUTPUT:
Github link:
[Link]

You might also like