Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.Math;
  3.  
  4. public class Lab6c
  5. {
  6.    public static void main(String[]args)
  7.         {
  8.             System.out.print("Enter the interest rate (As a percent): ");
  9.             Scanner scan = new Scanner(System.in);
  10.             double r = scan.nextDouble();
  11.             r /= 100;
  12.            
  13.             System.out.print("Now enter the principal amount: ");
  14.             double p = scan.nextDouble();
  15.            
  16.             System.out.print("How many years is this loan for: ");
  17.             int n = scan.nextInt();
  18.             n *= 12;
  19.            
  20.             double monthly_payment = (p * r * Math.pow(1+r, n)) / (Math.pow(r+1, n)-1);
  21.            
  22.             System.out.println("Your monthly payment is: " + monthly_payment + "$");
  23.         }          
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement