CPT206 Computer Programming for Financial Mathematics:
Resit Task Specification
Set: Monday 14 July, 2025
Due date: Sunday 27 July, 2025, 23:59
This is the specification task sheet for the resit assessment of your CPT206 module. The task covers all Learning Outcomes, and accounts for 100% of the final mark for this module. This assignment has two parts: a coding part described in Section 1, and a report described in Section 2. The submission deadline for this assignment is Sunday 27 July, at 23:59 (China-time). Detailed submission instructions are provided in Section 3.
1 Program description (70 marks)
The aim of this coursework is to build a loan calculator system. All the work should be coded into a single Java NetBeans project, with the class structure and different functionalities of the program described below. All classes should be properly encapsulated, as seen in the Lectures and Labs throughout the semester. Your project should also contain a main class for running the application.
1.1 (VariableInterest)Loan class (15 marks)
The Loan class will be a base class representing a loan. Each loan stores a principal (the amount of the loan), an annual interest rate, and a term (the duration of the loan, in years). Loans should be ordered as follows:
• If the terms differ, they should be ordered by term;
• If the terms are the same, they should be ordered by principal;
• If the terns and principals are both the same, they should be ordered by interest rate.
There will be a subclass VariableInterestLoan which allows for adjustment of the annual interest rate. The interest rate must remain between 1% and 20%. Adjustments are handled via a method adjustInterestRate(double ratio) which multiplies the interest rate by the specified ratio. If this would cause the rate to fall below 1%, it is simply adjusted to 1% instead. Similarly, if this would cause it to exceed 20%, it is adjusted to 20%.
1.2 PaymentEntry class (9 marks)
Loans need to be repaid. This process will normally follow a amortised payment schedule (see Section 1.3 where a certain amount of the loan is repaid every month for the duration of the loan. Each monthly payment will be an instance of the PaymentEntry class. A payment entry object will store the following information:
• the month number of the payment (i.e., a number between 1 and 12 times the term of the loan);
• the remaining balance on the loan prior to the payment;
• the payment amount, which will be broken down into principal paid and interest paid in that month.
1.3 AmortisationSchedule class (8 marks)
The AmortisationSchedule represents the entire payment schedule for a given loan. It simply stores a collection of PaymentEntry objects. When an AmortisationSchedule object is created, this collection is empty. The most frequent operation on this collection will be adding the latest payment. This should be done via an addPaymentEntry(PaymentEntry entry) method, and payment entries in the schedule should always be ordered from least recent to most recent (here, “recent” refers to the order in which entries are added to the schedule). You should choose an appropriate object of the Java collection framework to store the collection of payment entries in the schedule, and leave a comment in your code clearly detailing and explaining your choice.
1.4 LoanCalculator class (18 marks)
This class will store a Loan instance, and be responsible for various calculations related to this loan.
• The class should have a calculateMonthlyPayment() method. This calculates the regular monthly payment amount over the duration of the loan, when the interest rate is taken into account. You may apply the following formula:
(1)
where:
– M is the monthly payment amount (the quantity to calculate);
– P is the loan principal (the initial loan amount);
– r is the monthly interest rate (the annual interest rate divided by 12);
– n is the total number of payments (the loan term in years multiplied by 12).
• The class should have a method to generate the full amortisation schedule for repayment of this loan. The method should return an AmortisationSchedule as defined in Section 1.3 above. In this schedule, the successive monthly PaymentEntry objects are generated as follows:
– Before each monthly payment is made, there is a remaining balance on the loan, which will be the remaining balance for the payment entry.
– The interest paid in the entry is this remaining balance multiplied by the montly interest rate r from Equation (1) above.
– The principal paid in the entry is the difference between the total monthly payment amount given by M in Equation (1) and this interest paid.
– The first payment entry occurs in month number 1, the second in month number 2, and so on.
• The class should have methods to calculate the total payment amount and total interest paid over the course of the entire schedule.
1.5 File I/O (10 marks)
In order to create a more useful application that allows data to persist when the program stops running, you should add File I/O (Input/Output) elements to your program. File I/O refers to the process of reading data from and writing data to files on a storage medium (such as a hard drive). Since this not been taught in this course this semester, you will have to learn how to write suitable methods, and integrate them into your loan calculator project. To do this, you should enlist the help of XipuAI (for more details, see Section 2.3).
Your File I/O elements should allow data from your various classes to be stored in files in your computer system. You should select appropriate file types to do this (for example, a simple CSV file may not be appropriate for more complex data types). You should also include methods to load data from files into local memory when starting the program, and ensure this data is stored in appropriate data structures. In addition, your File I/O elements should incorporate exception handling according to best practices. Finally, you may wish to add more complex File I/O elements of your choosing to the program.
1.6 Code quality (10 marks)
The remaining marks (10) will be awarded for the quality of your code and documentation, as covered throughout the semester in the Lectures and Labs.
• Keep your code neat and tidy; make sure it is properly indented throughout.
• Choose suitable names for variables and methods, respecting standard Java naming conventions.
• Comment your code as needed.
• Split your code into separate methods as appropriate; methods should not be too long.
You should also write Javadoc comments for the entire API of the LoanCalculator class from Section 1.4, and submit the corresponding generated Javadoc file “LoanCalculator.html” (see detailed submission instructions in Section 3). You do not need to write Javadoc comments for the other classes.
2 Report (30 marks)
For this part of the assignment, you should write a report detailing how you designed, implemented, and tested the program described in Section 1. The report should be typed into e.g. a Word document, and submitted as a PDF (see Section 3 for more details). Where appropriate in the report, you should refer to specific lecture slides (or parts of Lab worksheets), e.g. “as seen in Lecture 10, slides 32-34”.
2.1 OOP features (10 marks)
Over the course of the semester, you have learned a number of OOP features (e.g encapsulation) and principles (e.g. single responsibility principle). In your report, you should explain where you have incorporated these in your design and how you have done so; include a brief definition of the features/principles in question. Be as precise as possible, illustrating with small portions of code if necessary. Note that not all the features and principles we saw in the lectures need to be incorporated into your design; your report should only discuss those that are. This section should be one-and-a-half to two pages in length.
Good example: The Single Responsibility Principle states that every class in the program should have responsibility over a single functionality of the program; a class should do one thing. This principle is incorporated into our class design: all the classes have their own, separate, purpose. For instance, the Loan class...
Bad example: Encapsulation and inheritance are two core features of OOP; they are used in many parts in my program.
2.2 Testing description (10 marks)
As covered throughout the Lectures and Lab sessions in this module, testing is an essential part of writing computer programs. In your report, you should include a description of how you tested the various parts of the program described in Section 1. Your testing may use the JUnit framework, or simply manually check cases in the main class. Your report should state clearly what functionalities you tested, and describe how you tested them, thinking carefully about possible corner cases. You may include some sample code if you wish. This section should be one-and-a-half to two pages in length (screenshots excluded).
2.3 AI-assisted File I/O (10 marks)
As stated above, you should use XipuAI to teach you how to incorporate File I/O elements into program. You may use AI in any part of this process. For example, you may wish learning about basic concepts of File I/O, exception handling, etc., or you might use AI for assistance in code-writing, and so on. In your report, you should explain which File I/O elements you have inclued in your program, and how they are implemented. This may include a discussion of the different file types for storing different data types, your exception handling mechanisms, any additional elements you chose to include, and so on. You should explain your use of XipuAI by detailing clearly how it helped you write and incorporate these elements, which aspects you used it for, and so on. Remember that you do not have to blindly accept all AI output as inherently correct: critical reflection on AI’s answers and suggestions will be welcome.
The marking for this section of the report will be broken down into 5 marks for the explanation of the File I/O elements and 5 marks for your use of AI tools. This section should be no more than two pages in length, screenshots excluded. You should attach the entire transcript. of your conversation(s) with XipuAI in an appendix to the report (you can save the entire conversation for example by clicking the “Export” button in the interface below).
3 Submission instructions
In the dedicated “Coursework 3 submission” Assignment activity on the Learning Mall Online, you will need to submit the following two (2) documents.
• A single ZIP archive of your entire NetBeans project. Include all the resources your project needs to run (including files that you wish to read from and/or write to). This file should be named “CPT206 Resit studentId.zip”.
• The online Javadoc API documentation file of your LoanCalculator class, as specified in Section 1.6. This is the “LoanCalculator.html” file generated by your project. You do not need to rename this file.
• Your report from Section 2, including the appendix of your conversation(s) with XipuAI, typed into e.g. a Word document, and converted into a PDF file. This file should be named “CPT206 Resit studentId.pdf”.
The submission deadline is: Sunday 27 July, 2025, at 23:59 (China-time).
This assignment is individual work. Plagiarism (e.g. copying materials from other sources without proper acknowledgement) is a serious academic offence. Plagiarism and collusion will not be tolerated and will be dealt with in accordance with the University Code of Practice on Academic Integrity. Submitting work created by others, whether paid for or not, is a serious offence, and will be prosecuted vigorously. The use of generative AI for content generation is permitted only in the design and implementation of your application’s file I/O elements, as detailed in Sections 1.5 and 2.3. No other use of generative AI for content generation is permitted on this assignment. Such a use would be considered in breach of the University Code of Practice on Academic Integrity, and dealt with accordingly. Individual students may be invited to explain parts of their code in person during a dedicated interview session, and if they fail to demonstrate an understanding of the code, no credit will be given for that part of the code.
Late submissions. The standard University policy on late submissions will apply: 5% of the total marks available for the component shall be deducted from the assessment mark for each working day after the submission deadline, up to a maximum of five working days, so long as this does not reduce the mark below the pass mark (40%); submissions more than five working days late will not be accepted.