From d4d5768758f45da627425acbbd22b072d3617199 Mon Sep 17 00:00:00 2001 From: bjv33 <bjv33@cs.drexel.edu> Date: Tue, 23 Oct 2018 21:18:26 -0400 Subject: [PATCH] Loan Payments --- LoanPayments.java | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 LoanPayments.java diff --git a/LoanPayments.java b/LoanPayments.java new file mode 100644 index 0000000..0f1089d --- /dev/null +++ b/LoanPayments.java @@ -0,0 +1,41 @@ +// Program: LoanPayments.java +// Purpose: This program calculates how much of your loan payment goes to the principal and how much goes to interest. +// Author: Brian Vojtko +// Date: 10/09/2018 + +import java.util.Scanner; + +public class LoanPayments +{ +public static void main(String[] args) + { + //Introduction Display + System.out.println ("Loan Payments"); + System.out.println("-----------------"); + System.out.println("This program calculates how much of your loan payment goes to the principal and how much goes to interest."); + System.out.println(" "); + + Scanner scan = new Scanner(System.in); + + //Monthly Payment Input + double payment = 0.00; + System.out.println("Enter your monthly payment: $"); + payment = scan.nextDouble (); + + //Outstanding Balance Input + double balance = 0.00; + System.out.println("Enter your outstanding balance: $"); + balance = scan.nextDouble (); + + //Calculation + double interest = payment * 0.0451; + double principal = payment - interest; + interest = (double)((int)((interest + 0.005) * 100))/100; + principal = (double)((int)((principal + 0.005) * 100))/100; + + //Display Results + System.out.println("From your payment of $" + payment + ","); + System.out.println("$" + interest + " goes to interest."); + System.out.println("$" + principal + " goes to the principal."); + } +} -- GitLab