FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

update F015_ProjectMortgageCalculator, yно требуется доделать формулу · windweb/JavaTutorial@2fffc81 · GitHub

Commit 2fffc81

Browse files
committed
update F015_ProjectMortgageCalculator, yно требуется доделать формулу
1 parent 6ba4c0a commit 2fffc81

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1+
import java.util.Scanner;
2+
13
public class F015_ProjectMortgageCalculator {
24
public static void main(String[] args) {
3-
5+
// Principal: $100,000
6+
// APR: 3.92
7+
// Years: 30
8+
System.out.print("Principal: ");
9+
Scanner input = new Scanner(System.in);
10+
double principal = input.nextDouble();
11+
System.out.print("APR: ");
12+
double apr = input.nextDouble();
13+
System.out.print("Years: ");
14+
int years = input.nextInt();
15+
// mortgage
16+
double monthlyInterest = apr / 1200;
17+
double monthlyPayment = principal * monthlyInterest / (1 - 1 / Math.pow(1 + monthlyInterest, years * 12));
18+
double totalPayment = monthlyPayment * years * 12;
19+
System.out.println("Mortgage: " + totalPayment);
420
}
5-
}
21+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL