Java代写 | COMP251 – Assignment 4

本次Java代写是使用优先级队列为有资金的金融机构实施贷款批准系统

COMP251 – Assignment 4
Application:
New applications are stored in a file which is the input of load or update command. Each
application contains different fields and will be stored as a separate line in the input file. The
following are the application’s fields:
– Applicant’s full name (can be stored as a string)
– Loan amount that is requested
– Years of relevant education
– Years of relevant experience
– Estimated annual profit: it is a list of estimated profit for the financial institute from the
customers’ payback in each year (for up to 30 years). Note that different applicants may
differ in the length of estimated annual profit.
Approval process:
The financial institute will keep applications in three lists. Once the applications are read from
the input file, they will be checked to see if they meet the requirements or not and based on that
added to the active application list or rejected list. If the sum of education and experience years is
smaller than 10, the application will be rejected. Otherwise the application will get some score
and will be added to the active list. The following formula is used to calculate the score of active
applications:
score : ∑
n−1
i=0
(i+1)
estimatedAnnualProfit [i]
where estimatedAnnualProfit[i] is the estimation of annual profit for year i after approval (it is a
part of the application form).
Note that in the case of update command, the score of the application will be calculated again
and it will be updated in the active list, or if the application was rejected before, it might change
the status and add it to the active list.
Sample Input
The following is an example of an input file:
“Maryam Siahbani” 150000 10 3 0 0 24000 40000 50000 24000
“John Smith” 150000 6 3 0 0 25000 50000 50000 25000
“Larry Page” 150000000 8 25 0 150000000
“Some Guy” 120000 4 13 0 60000 90000 40000
“Some Gal” 120000 7 10 0 60000 90000 40000
Each line is one application and different fields of each application are separated by tab (“\t”).
In the first application, the applicant’s full name is “Maryam Siahbani”, the requested loan is
150000$, years of relevant education is 10, and years of relevant experience is 3, and estimated
annual profit is [0, 0, 24000, 40000, 50000, 24000]. So for this applicant the score will be
calculated as 0*1/1 + 0* 1/2 + 24000 * 1/3 + 40000* 1/4 + 50000 * 1/5 + 24000* 1/6 = 32000.
A sample input file will be posted to Blackboard as an example, make sure you follow the input
format.
Note that the approval of the applications depends on their priority scores and the available
budget. For example in the above example, assume that the institute budget is set to 300000, then
the input file is given to the loan-approval application and then command “make decision” is
requested and finally command print. The result in the active.txt, approved.txt and
rejected.txt files will be as follows:
active.txt:
“Larry Page” 150000000 75000000
“Maryam Siahbani” 150000 32000
approved.txt:
“Some Gal” 120000
“Some Guy” 120000
rejected.txt
“John Smith” 150000
Note that although the priority score of “Larry Page” was higher than others it was not approved,
due to lack of budget. The applications in the active list will be printed based on the priority
score (sorted in decreasing order). The last field in each line of active.txt is the priority score.
Guideline:
You need to implement and submit at least 4 classes:
– Applicant: this class keeps the information for each applicant, name, education,
experience,… . This class should also have a field called score (see the Approval
process for the details). This class should implement interface Comparable (define
method compareTo() which compares regarding the value of score).
– PriorityQueue: your priority queue should be a max heap. You can use the java code
for lab7. That is a min heap, update it and create a max heap (give the priority to larger
values). Make sure that you keep this class a generic class just like the original code in
lab7 (do not use any specific field from other classes in this assignment).
– Loan: This is the main class for loan approval. This class should keep three lists: active
applications, approved applications and rejected applications. The approved and rejected
lists can be a regular ADT List (you can use ArrayList in Java API). The active
application list should be a priority queue (create an object of PriorityQueue that
you have implemented).
– test: This class is just for testing. It will include method main, just create an object of
class Loan and test it. In class Loan you should have a method called run() which
prints the options for the user and executes them.
Important Remarks
It’s very important that you make sure your program compiles without any problem (you may
get 0 if your program doesn’t compile)
For this project, you must work alone!
By alone rule: All code that you submit should be written by you alone, except for small
snippets that solve tiny subproblems (of course you are allowed to use the source codes we
discussed in class or I post on blackboard).
Do Not Possess or Share Code: Before you’ve submitted your final work for a project, you
should never be in possession of solution code that you did not write. You will be equally
culpable if you distribute such code to other students or future students of COMP251 (within
reason). DO NOT GIVE ANYONE YOUR CODE – EVEN IF THEY ARE DESPERATELY
ASKING. DO NOT POST SOLUTIONS TO PROJECTS ONLINE (on GitHub or anywhere
else)! If you’re not sure what you’re doing is OK, please ask.
Permitted:
● Discussion of approaches for solving a problem.
● Giving away or receiving significant conceptual ideas towards a problem solution. Such
help should be cited as comments in your code. For the sake of other’s learning
experience, we ask that you try not to give away anything juicy, and instead try to lead
people to such solutions.
● Discussion of specific syntax issues and bugs in your code.
● Using small snippets of code that you find online for solving tiny problems (e.g. googling
“uppercase string java” may lead you to some sample code that you copy and paste into
your solution). Such usages should be cited as comments in your hw, lab, and especially
project code!