Hello, I am a novice working with Java. I am creating an amortization schedule (pictured below) and have run into an issue. As visible in the example, everything but the final "Amortized" value on the chart is functional. Why is this and how do I fix it?
I believe this may be tied to my "monthint" value and how it handles the "balance" value. Perhaps it's directly tied to my logic behind the "amorized" variable in the loop?
import java.util.Scanner;public class taxAmortization {public static void main(String[] args) {Scanner inKey = new Scanner(System.in);double principal,interest,repay,monthint,amorized,intdate,balance,finalbal;int month;System.out.println("What is the principal on your loan?");principal = inKey.nextDouble();System.out.println("What is the interest rate on your loan? (In percent)");interest = inKey.nextDouble();System.out.println("What is your monthly loan payment?");repay = inKey.nextDouble();intdate = 0;month = 0;finalbal = 0;balance = principal;System.out.println("\t\t\t\t AMORTIZATION TABLE\n\t\tPRINCIPAL: $" + principal + " INTEREST: " + interest + "% \n\t\t\t REGULAR PAYMENT $" + repay + "\n NO.\tINTEREST\tAMORTIZED\tBALANCE\t INTEREST TO DATE");while (balance > 0) {month = month+1;monthint = ((interest / 100)/12) * balance;amorized = repay - monthint;balance = balance - amorized;intdate = intdate + monthint;if (balance > 0) {finalbal = balance;}else{finalbal = 0;}System.out.printf(" %d\t\t%.2f\t %.2f\t %.2f\t %.2f",month,monthint,amorized,finalbal,intdate);System.out.println();}}}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here