fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. double monthlyPayment;
  13. int years = 30;
  14. int n = years * 12;
  15. int mortgage = 225000;
  16. double interestRate = 3.75;
  17. double monthlyInterest = (interestRate / 100) / (12);
  18. monthlyPayment = (monthlyInterest * mortgage) / (1 - Math.pow((1 + monthlyInterest), - n));
  19. System.out.println("Mortgage Calculator - M. Stacy \n");
  20. System.out.println("Present Value: " +mortgage);
  21. System.out.println("Term (years): " +years);
  22. System.out.println("Terms (months):" +n);
  23. System.out.println("Rate: \t " +interestRate);
  24. System.out.println("Payment: $"+monthlyPayment);
  25.  
  26.  
  27. }
  28. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
Mortgage Calculator - M. Stacy 

Present Value: 225000
Term (years):  30
Terms (months):360
Rate: 	 3.75
Payment: $1042.0100810372794