Question: Loan Server: Write a server program in java to handle client requests for calculation of Loan payment amounts. The client sends loan information (annual interest

Loan Server:

Write a server program in java to handle client requests for calculation of Loan payment amounts. The client sends loan information (annual interest rate, number of years, and loan amount) to the server. The server computes the monthly payment and total payment (using a simple interest calculation) and sends them back to the client. Create a simple User Interface (UI) for the client program to enter the loan information and submit the request to server. The payment information sent by the server should be displayed on the client UI.

Use a Loan class that has annual interest rate, number of years, and loan amount as its data fields and pass the Loan object to the server.

The server should be able to handle multiple clients.

Submit the following files:

Loan.java

LoanServer.java

LoanClient.java

//This Loan.java was given by professor to implement it to LoanClient.java which has to be created and LoanServer.java

public class Loan

{

private double annualInterestRate;

private int numberOfYears;

private double loanAmount;

private java.util.Date loanDate;

//Default construct

public Loan()

{

this(2.5, 1, 1000);

}

/*

* Construct a loan with specified annual interest rate,

* number of years, and loan amount

*

*/

public Loan(double annualInterestRate, int numberOfYears, double loanAmount)

{

this.annualInterestRate = annualInterestRate;

this.numberOfYears = numberOfYears;

this.loanAmount = loanAmount;

loanDate = new java.util.Date();

}

/*

* Return annualInterestRate

*/

public double getAnnualInterestRate()

{

return annualInterestRate;

}

/*

* sets the annual interest rate

*/

public void setAnnualInterestRate(int annualInterestRate)

{

this.annualInterestRate = annualInterestRate;

}

/*

* this will return the number of years

*/

public double getNumberOfYears()

{

return numberOfYears;

}

/*

*this will set the number of years

*/

public void setNumberOfYears(int numberOfYears)

{

this.numberOfYears = numberOfYears;

}

/*

* this gets the loan amount

*/

public double getLoanAmount()

{

return loanAmount;

}

/*

* this will set the loan amount

*/

public void setLoanAmount(double loanAmount)

{

this.loanAmount = loanAmount;

}

/*

* Find the monthly payment

*/

public double getMonthyPayment()

{

double monthlyInterestRate= annualInterestRate/1200;

double monthlyPayment= loanAmount*

monthlyInterestRate/ (1- (1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)));

return monthlyPayment;

}

/*

* Find total payment

*/

public double getTotalPayment()

{

double totalPayment = getMonthyPayment() * numberOfYears * 12;

return totalPayment;

}

/*

* Return loan date

*/

public java.util.Date getLoanDate()

{

return loanDate;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!