Change to oop format import java.util.Scanner; import java.io.*; import java.text.DecimalFormat; public class Amortization { /* call values in, set balance and principle. set month to increment until reaching number provided. use \t to space out result well. Use PritWriter output instead of System.output to make the notepad file.*/ public static void createReport(String filename, double loan, double interestRate, int years) throws IOException { PrintWriter output = new PrintWriter(new FileWriter(filename)); double monthlyPayment = calcPayment(loan, interestRate, years); int numberOfPayments = getNumberOfPayments(years); double balance = loan; output.println("{Monthly Payment}: " + monthlyPayment); output.println("{Month} \t {Interest} \t {Principal} \t {Balance}"); for (int month = 1; month <= numberOfPayments; month++) { double interest = balance * (interestRate / 12); double principal = monthlyPayment - interest; balance -= principal; output.printf("%d \t \t %.2f \t \t %.2f \t \t %.2f \\\n", month, interest, principal, balance); } output.close(); } public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); DecimalFormat df = new DecimalFormat("#.##"); do { /* Data members */ double loan; int years; double interestRate; /* Get amount, interest rate, and years from the user */ System.out.println("Enter the loan amount: "); loan = keyboard.nextDouble(); System.out.println("Enter the annual interest rate: "); interestRate = keyboard.nextDouble() / 100.0; System.out.println("Enter the years of the loan: "); years = keyboard.nextInt(); double payment = calcPayment(loan, interestRate, years); if (payment < 0) { System.out.println("Invalid input values."); } else { System.out.println("Monthly Payment: " + df.format(payment)); int numberOfPayments = getNumberOfPayments(years); System.out.println("Total Number of Payments: " + numberOfPayments); try { createReport("LoanAmortization.txt", loan, interestRate, years); System.out.println("Report created successfully."); } catch (IOException e) { System.out.println("Error creating report: " + e.getMessage()); } } System.out.println("Would you like to run another report? Enter Y for yes or N for no: "); } while (keyboard.next().equalsIgnoreCase("Y")); keyboard.close(); } public static double calcPayment(double loan, double interestRate, int years) { double term = Math.pow(1 + (interestRate / 12), years * 12); double payment = (loan * (interestRate / 12) * term) / (term - 1); return payment; } public static int getNumberOfPayments(int years) { return years * 12; // Assuming monthly payments for the given number of years } public static void createReport(String filename) throws IOException { // Sample implementation to save data to a file PrintWriter out = new PrintWriter(new FileWriter(filename, true)); out.println("Sample Data"); out.close(); } }.