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.
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
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
The technical specifications of the program are as follows:
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