Java program to pay and calculate mortgage, loan, and insurance payment. Your mortgage payment is the method by which you repay your home loan.

This is usually a once-a-month payment that helps you pay off your mortgage gradually. It will also include payments for your lender’s interest, insurance, and taxes.

import java.util.Scanner;

class Main

{

public static void main(String arg[])

{

Scanner scan = new Scanner(System.in);

System.out.print("Enter the principal money ");

double principal = scan.nextDouble();

System.out.print("Enter rate of interest per principal amount");

double rate = scan.nextDouble();

rate =( rate/100)/12;

System.out.print("Enter duration of the loan amount");

int time = scan.nextInt();

time = time * 12;

double p= (principal * rate) / (1 - Math.pow(1 + rate, -time));

System.out.println("Your payment is" + p);

}

}

Output:

Enter the principal money 1500000

Enter the rate of interest per principal amount7

Enter the duration of the loan amount20

Your payment is11629.484034283096

## What is the difference between nextin and nextdouble in java

**NextDouble**

The Java Scanner class has a method called nextDouble() that scans the next token of the input as a double. The scanner passes the input that matched if the translation was successful.

**nextLine()**

The java. util. nextLine() function is used to get the next line in a string. The Scanner class searches for a line separator delimiter starting at the current location. The String from the current place to the end of the line is returned by this method.

## What is mortgage and how its differ from pledge

**Mortgage**

The principal is the amount you borrow with your mortgage. Part of your monthly payment will be used to pay down the main, or mortgage debt, and the rest will be used to pay interest on the loan. The lender charges you interest for the lending you money.

**Pledge**

In the case of mobile properties, a pledge is utilised, and in the case of immovable goods, a mortgage is used. The items are kept with the lender in the case of a pledge, whereas mortgaged properties are kept with the borrower.

## How to calculate mortgage in calculator

If you wish to calculate your monthly mortgage payment by hand, you’ll need the monthly interest rate, which you can get by dividing the annual interest rate by 12 months (the number of months in a year). The monthly interest rate, for example, would be 0.33 percent (0.04/12 = 0.0033) if the yearly interest rate is 4%. 01.

**What is the rate of interest and how to calculate it**

**rate=(rate/100)/12**

The interest rate is the percentage of the principal that a lender charges for the use of assets. The annual percentage rate (APR) is used to express the interest rate on a yearly basis (APR). Cash, consumer goods, or significant assets like a vehicle or a building could be used as collateral.