CMPT 225 Assignment 1: Loan management system

CMPT 225 Assignment 1: Loan management system

Due Sunday Oct 1st, 2017, 23:59 pm


You are writing a start-up-loan approval system for a bank.

The bank takes a maximum of 5000 loan applications and deny them only if the applicant doesn't qualify (he/she is not educated or experienced in the field). If the applicant qualifies, the loan will be eventually approved (although there is no guarantee if that happens in the lifetime of the applicant!).

The bankers may write commands like the following:

save_application
  parameters:
    string applicant_full_name // This is unique and identifies a loan_application.
    int years_of_relevant_education
    int years_of_relevant_experience
    int loan_amount
    int* estimated_yearly_profits // A sequence for how much the bank would profit from the customers' payback in each year (for up to 30 years)
  explanation: saves the incoming application into an active_applications list

make_decisions
  parameters:
    string decision_date
    int budget
  explanation: denies the applications (i.e. removes them from active_applications and saves them to denied_applications list) where the sum of education and experience years is smaller than 10. Approves applications (i.e. removes them from active_applications and saves them to approved_applications list) in the order of their priority (defined later) if enough money is left from the given budget. priority is defined as

print
  explanation: prints the active_applications, approved_applications, and denied_applications, to the standard output. It writes the name of the list following by all the items (in any order) separated by the tab character ('\t') or the space character (' '). Each item in active_applications list is printed as ("full_name",loan_amount) and each item in the other two lists is printed as ("full_name",loan_amount,"decition_date"). Make sure you don't add extra spaces or tabs inside the parantheses.
  Please remember that we do exact string match to check the print output. So, watch for the seemingly small mistakes like adding an extra space, dropping quotations, etc.
  Also, while we do not care about the order of items in printed lists, we do care about the decision_date in approved or denied applications.

input to the program:

The commands are saved in a text file, each at a line where the command and parameters are separated via the tab character('\t'). The program reads the file and runs the commands. For example if the following is the content of a commands.txt file
save_application	"Golnar Sheikhshab"	10	3	150000	0	0	24000	40000	50000	24000
save_application	"John Smith"	6	3	150000	0	0	25000	50000	50000	25000
save_application	"Larry Page"	8	25	150000000	0	150000000
save_application	"Some Guy"	4	13	120000	0	60000	90000	40000
save_application	"Some Gal"	7	10	120000	0	60000	90000	40000	
make_decisions	"Oct 2nd, 2017"	300000
print
In the first application, the applicant_full_name is "Golnar Sheikhshab", the years_of_relevant_education and years_of_relevant_experience are 10 and 3 respecitvely, the loan_amount is 150000, and estimated_yearly_profits is {0, 0, 24000, 40000, 50000, 24000} making the priority = 0*1/1 + 0* 1/2 + 24000 * 1/3 + 40000* 1/4 + 50000 * 1/5 + 24000* 1/6 = 32000. Note that the number of years in estimated_yearly_profits differ from application to application.

To avoid bad input format, you can download this example of commands.txt from here.

Here is what happens when we run the program

./loan_approval.o	commands.txt
active_applications	("Larry Page",150000000)	("Golnar Sheikhshab",150000)
approved_applications	("Some Guy",120000,"Oct 2nd, 2017")	("Some Gal",120000,"Oct 2nd, 2017")
denied_applications	("John Smith",150000,"Oct 2nd, 2017")
The program should be compiled as follows:
g++ -c loan_application.cpp
g++ -o loan_approval.o loan_approval.cpp loan_application.o

What to submit?

  1. loan_approval.cpp
  2. loan_application.h
  3. loan_application.cpp

Where to submit?

In CourSys under CMPT 225 Assignment1 activity.

What code can you reuse?

Use the implementation of list that was provided for lab1. You may overload operator[] to access item i in the list if you need to. Do not change anything else as you will not be able to upload your version of ArrayList or SortedArrayList. We will test your program using the implementation provided for lab1, only we'll aso add the implementation of operator[].

How to test?

  1. Download this zip file, unzip it, and copy all the files it contains next to your .h, .cpp, and .o files.
  2. compile check_output.cpp to get check_output.o.
  3. run
    ./check_output.o expected.txt expected.txt
    ./check_output.o expected2.txt expected2.txt
    ./check_output.o expected3.txt expected3.txt
    
    and make sure all 3 score you get are 1.

By the way, you can use check_output.cpp as a sample for how to read from file, do tokenization, and use STL containers vector and set.

Milestone for partial mark