Question 12
AQA Computer Science November 2020 Paper 1 (7517/1)A level11 marks
On the specification
- 12.1
- 4.1 Fundamentals of programming3.1 Fundamentals of programming
Question text
12 This question extends the Skeleton Program by adding the facility for a company to obtain a loan to increase their balance. When a company chooses to get a loan, 10 000 is added to their balance. The company should only be allowed to get a loan if they do not already have a loan that has not been paid back. The user will be asked to specify the daily interest rate for the loan. The company can pay back all or part of the loan at any time. The program should keep track of the amount of the loan that the company still needs to pay back. Each time the simulation is advanced by a day, the company will have their balance reduced by an amount equivalent to the interest rate applied to the amount of the loan minus any repayments that have been made. Figure 5 shows an example of the calculation. Figure 5 A company has repaid 1500 of the loan meaning that it still owes 8500. The interest rate for the loan was 0.0005% and the company’s current balance is 4000. The simulation is advanced by a day and the company’s balance is reduced by 0.0425 to 3999.9575 (0.0425 is 0.0005% of 8500). To get full marks on this question you will need to make use of encapsulation to hide attributes in the Company class. What you need to do Task 1 Add attributes to the Company class named LoanBalance and InterestRate. LoanBalance should be used to track the amount of the loan that the company needs to pay back. InterestRate should be used to store the interest rate at which the loan was taken. Task 2 Modify the ModifyCompany method in the Simulation class so that there are options on the menu to get a loan and to pay back a loan. Task 3 Modify the Skeleton Program so that if a company has a loan balance of 0 then it can take out a loan. When it does: • 10 000 should be added to Balance and LoanBalance • InterestRate should be set to the value specified by the user. Task 4 Modify the Skeleton Program so that when a company chooses to pay back a loan the user is asked how much to pay back and the values of LoanBalance and Balance are reduced by this amount. You do not need to check that the value entered is sensible or that the company has a loan to pay back. Task 5 Modify the ProcessDayEnd method in the Company class so that the company’s daily interest for the loan is subtracted from the company’s balance. Task 6 Test that the changes you have made work: • run the Skeleton Program • choose to use a normal size settlement • choose to use the default companies • give the company AQA Burgers a loan with a percentage interest rate of 0.015 • advance the simulation • get the company AQA Burgers to pay back 500 of the loan • advance the simulation • then choose the menu option to display the details of the companies. Evidence that you need to provide Include the following evidence in your Electronic Answer Document. 12.1 Your PROGRAM SOURCE CODE for the amended parts of your Skeleton Program. You should include the entire code for each method you have changed/created. [10 marks] 12.2 SCREEN CAPTURE(S) showing the requested test. You only need to show the result of choosing the menu option to display the details of the companies. Evidence for the earlier parts of the test is not needed. [1 mark]