114k views
2 votes
Submit - An application that reads input from a file to create an array of LoanAccount[] objects and then calculates monthly payments for all the LoanAccounts. Finally, write all the LoanAccount objects to a text file, including the monthly payments and total interest paid (like we did in our previous labs). Be sure to use file input method in your loop structure to determine when

User Carpela
by
7.8k points

1 Answer

4 votes

Final answer:

To create an array of LoanAccount[] objects from input file data and calculate monthly payments, follow these steps: open the input file, read the data line by line, split each line into the required fields, create a new LoanAccount object using the extracted data, calculate the monthly payment using the LoanAccount object's attributes, and write the LoanAccount object and its monthly payment to the output file.

Step-by-step explanation:

To create an array of LoanAccount[] objects from input file data and calculate monthly payments, you can follow these steps:

  1. Open the input file
  2. Read the data line by line
  3. Split each line into the required fields (e.g., loan amount, interest rate, term)
  4. Create a new LoanAccount object using the extracted data
  5. Calculate the monthly payment using the LoanAccount object's attributes
  6. Write the LoanAccount object and its monthly payment to the output file

Make sure to handle any exceptions that may occur during file operations, input parsing, and calculation.

User Scomes
by
7.8k points