IM writing a monthly mortgage payment calculator I have the formula but dont know how to enter it:

the formula i have is

pmt = ((p-d)*r/12) / (1-(1+(r/12)^-m)

my code is:

import java.util.Scanner;

public class Project1 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("Enter the price of the house: ");

double housePrice = input.nextDouble();

System.out.println("Enter the down payment: ");

double downPayment = input.nextDouble();

System.out.println("Enter the annual interest rate: ");

double annualInterestRate = input.nextDouble();

System.out.println("Enter the number of payments: ");

double numberofPayments = input.nextDouble();

double monthlyPayment= ( ((housePrice - downPayment) * (annualInterestRate/12)) /((1-(1+(annualInterestRate/12)^-numberofPayments))));

}

}

I dont know how to enter this formula maybe there is a simpler way?

--- Update ---

In which PMT is the monthly payment, P is the listed price of the house, D is the

down payment, r is the annual interest rate and m is the number of payments.