| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,21 @@ | |||
| 1 | + import java.util.Scanner; | ||
| 2 | + | ||
| 1 | 3 | public class F015_ProjectMortgageCalculator { | |
| 2 | 4 | 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); | ||
| 4 | 20 | } | |
| 5 | - } | ||
| 21 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments