Refer following code for mortgage calculator:
Code:
import java.io.*;
import java.util.Date;
import java.text.DecimalFormat;
public class Mortgage
{
public static void main(String[] args);
{
Date currentDate = new Date();
//Date constructor
DecimalFormat decimalPlaces=new DecimalFormat("0.00");
//declaring variables
final double PRINCIPAL = 200000;
final double INTEREST = .0575;
final double TERM = 12*30;
//declaring variables
final double MONTHLY = (((PRINCIPLE*(INTEREST/12))/(1-Math (1+(INTEREST/12))-(TERM)))
//displaying variables
System.out.println("tt" + currentDate);
System.out.println("ttPrinciple or Loan Amount: " + PRINCIPLE);
System.out.println("ttInterest Rate: " + INTEREST);
System.out.println("ttThe Term of Loan (in months): " + TERM);
System.out.println("ttThe Monthly Payment is: " + MONTHLY);
System.out.println(decimalPlaces.format(MONTHLY));
}
}
Bookmarks