Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.Math;
- public class Lab6c
- {
- public static void main(String[]args)
- {
- System.out.print("Enter the interest rate (As a percent): ");
- Scanner scan = new Scanner(System.in);
- double r = scan.nextDouble();
- r /= 100;
- System.out.print("Now enter the principal amount: ");
- double p = scan.nextDouble();
- System.out.print("How many years is this loan for: ");
- int n = scan.nextInt();
- n *= 12;
- double monthly_payment = (p * r * Math.pow(1+r, n)) / (Math.pow(r+1, n)-1);
- System.out.println("Your monthly payment is: " + monthly_payment + "$");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement