Introduction

You are required to write a program that will read loan transactions from a data file and perform the calculations to provide the loan summary report in a suitable format.

Program Output

The program calculates the monthly payment and total payment and displays them in report format along with the loan information provided. In addition to calculating monthly payment and total payment, a summary of information on loan profits and averages must also be displayed. Finally, a list of high-performing loans, those loans that earn at or above average profit, should be displayed.

A sample of a loan summary report is shown in figure 1.

Car Loan Detail
===============
LoanID Borrower Loan Amount Term Rate Payment Total Payment
12345 Bud Brown $10,100.00 60.0 4.0 $186.01 $11,160.60
67890 Barnie Miller $29,500.00 48.0 4.5 $672.70 $32,289.60
---------- ------- ----------
Total Loan Profit $3,850.20 Average $429.36 $21,725.10
Average Loan Profit $1,925.10

High Performing Loans (at or above average profit)
=====================
LoanID Borrower Loan Amount Total Payment Profit
67890 Barnie Miller $29,500.00 $32,289.60 $2,789.60

A menu allows the user to select what data is used and how the information is displayed. It allows different data files to be selected at run time and formats the data so that the report appears sorted by last name, by loan amount or by monthly payment. Figure 2 shows a sample of the user menu.

Loan Summary
============
Enter file name: loan.dat
Enter option or M for menu: m
Car Loan Options
================
E – Enter a loan
F - Read another file
N – Sort by borrower
A – Sort by loan amount
P - Sort by monthly payment
S – Save report to file
Q - Quit
Enter option: p

Financial Calculations

The formulae for calculating the monthly payment, monthly interest rate, and estimated total payment are given as follows:

monthly payment = loan amount * monthly interest rate / (1 – (1 + monthly interest rate) ^ -loan term in months)
monthly interest rate = yearly interest rate / 12
estimated total payment = monthly payment * loan term

Technical Specifications

The technical specifications of the program are as follows:

  • Numerical amounts must be corrected by applying round-off techniques (i.e. estimated total payment must equal monthly payment x loan term)
  • The loan plan information will be read into the program from a data file. (see figure 3) The file is to be read one time only (i.e. read the data into the program and then process)
  • A loan object must be instantiated for each record read using a class definition based on the provided UML class diagram (see figure 4). The loan objects are to comprise the array of objects. The Loan class enforces the following business rules with exceptions
    • loan amount must be between $10,000.00 and $100,000.00 (inclusive)
    • rate must be between 0 and 100 (inclusive)
    • term cannot be negative
    • loan id cannot be empty
    • borrower cannot be empty
  • The program must not crash (implements proper exception handling)
  • The program must display a menu of options to the user that include:
    • Enter new loans
    • View the report sorted by borrower’s name
    • View the report sorted by loan amount
    • View the report sorted by monthly payment
    • Save the report to a file (as currently sorted)
    • Open another file for input
    • Option to quit the program
  • The output must be accurate and properly formatted (i.e. numerical data right justified, text left justified, currency amounts properly formatted, etc.)
  • The program must be modularized using methods as follows:
    • A method to compute monthly payment
    • A method to compute total payment
    • A method to display one line loan of the loan summary report, such as the following: “12345 Bud Brown $10,100.00 60.0 4.0 $186.01 $11,160.60”
    • A method to load the array of loans
    • A method to display the loan detail report
    • A method to display the column summary (total loan profit and average loan profit)
    • A method to display a list of high performing loans
    • A method to write the report to a file
    • Other methods may be included if they are functionally cohesive

Sample date file

LoanId,Borrower,Amount,Rate,Term
12345,Bud Brown,10100.00,4.0,60
67890,Barnie Miller,29500.00,4.5,48
95135,Earl Sinclair,95387,5.0,36
12346,Roger Redmond,22000,5.5,24
12347,Chuck Farmer,10000.00,6.0,18

UML Class Diagram

- LoanId : String
- Borrower : String
- Amount : Real
- Rate : Real
- Term : Integer
+ Loan(LoanId : String)
+ GetLoanId() : String
+ GetBorrower() : String
+ SetBorrower(Name: String) : Void
+ GetAmount() : Real
+ SetAmount(Amount: Real) : Void
+ GetRate() : Real
+ SetRate(Rate: Real) : Void
+ GetTerm() : Integer
+ SetTerm(Term: Integer) : Void
+ GetMonthlyPayment() : Real
+ GetTotalPayment() : Real
+ GetProfit() : Real
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.