Python代写 | CEGE0096: Point-in-Polygon Test 1st Assignment (50%)
Faculty of Science and Technology
4483 Software Technology 1 and
8995 Software Technology 1 G
Semester WT, 2019
Main Assignment Part 1
(25% of grade Optional Assignment)
Due: End Week 7 (Submission on Canvas)
The House Cost Calculator Assignment
GENERAL INSTRUCTIONS
This assignment should be done individually. The submission should be made as a single zipped file including a BlueJ project and submitted in Canvas.
Students should be aware that I may do some kind of plagiarism check.
Note: code must be in BlueJ, code written and submitted in any other Java environment may not be able to be marked.
This assignment is marked as a submission of a single zip file. It should be submitted to Canvas by its due date (see above). You need to submit:
- The java program code (working or not) as a BlueJ project directory;
- A test plan;
- Documented results of your test plan;
- Evidence of you running a number of mandatory, well documented, test runs (e.g. screen shots); These are the results of mandatory test runs (test runs are detailed in a separate document);
- A short reflection report on what you learned;
- An optional feedback (of the unit). Just a paragraph to me which is not marked;
- Remember:” a single zipped file including a BlueJ project and submitted in Canvas.”
There are no resubmission options for this assignment.
This assignment is marked after semester ends in the exam period, resubmissions will NOT be possible.
You can ask for help in the tutorials, PALS, and hints, but the assignment should be your own work.
Assignment Briefing:
This is similar to MT1 with the following main changes.
- The Bank and Interest rates table is read from a file ‘BankIr1.txt’ or BankIr2.txt (these represent different date periods. Interest rates are lower in BankIr2.txt; Imagine hearing that the reserve bank of Australia lowered interest rates);
- There is a HOME3 loan type in some banks with just a 25 year repayment period instead of the 30 years applied to all loans
- Calculation of stamp duty is included as an extra cost
- There is an extra report called the investor comparison report where the input details of the investor report are read from a file of possible property deals that the investor is considering. The program then automatically finds the best one (the one with either the best profit or lowest cost)
- You need to do some documentation (reflection report and test plan);
- You need to run (and document – probably with screen shots) some mandatory tests (mandatory test runs are detailed in a separate document)
- You need to zip up the project as a BlueJ project with the documentation and submit it on Canvas.
Important NOTE: You do need to allow for input of non-numeric in numeric inputs. My test cases will include things like entering ‘fred’ in the ‘cost of property’ field. So, you need to use exceptions.
There are 6 mandatory test you must run and document (these are in a separate document). I expect you to run and document additional tests that you have written yourself.
Here in Australia the housing market is divided into mainly two kinds of purchasers.
- First Home Buyers
- Investors
The system you need to build helps both kinds of customers with different reports by providing the following services:
- For first home buyers it will give them a report on how much they need to pay each month as a repayment;
- For investors it will report if the property is positive or negative cash flow;
The Bank Id, Loan Type, current Interest Rate, loan establishment fee, and the maximum percentage of purchase price to be borrowed are read from the file ‘BankIr1.txt’:
Below is a copy of the file BankIr1.txt
WESTPAC,HOME,3.69,395,80
WESTPAC,INV,3.69,395,95 COMB,HOME,3.69,600,95 COMB,INV,3.72,600,95 ANZ,HOME,3.28,500,95 ANZ,HOME2,3.22,600,80 ANZ,HOME3,3.20,900,85 NAB,HOME,3.53,790,90 NAB,INV,3.63,190,95 INTEL,INV,4.86,0,95 BEYOND,HOME2,3.69,0,95 |
Note advanced students should read this into several arrays or even just one array with a data class, but it’s also possible to just open the file when you need it and look for the one line you need thus you don’t need to use arrays to complete the assignment for a good mark.
You can assume that these files BankIr1.txt and BankIr2.txt do not contain errors, in that all fields are in range and the correct type.
- For HOME, HOME2 and INV Loans the term in Years is 30 years (or 30*12 months = 360 months, 360 Payments); but
- For HOME3 Loans the term in Years is 25 years (or 25*12 months = 300 months, 300 Payments);
Stamp Duty is based on the value of the property and varies as shown on the following table. The value is rounded to the nearest dollar (using normal mathematical rounding). It is discounted for first home buyers who are buying a house up to $750,000 in value
Low value | High Value | First Home Buyer | Investor | |
$0 | $200,000 | $20 | $20 | |
$200,001 | $300,000 | $500 | $2,600 | |
$300,001 | $500,000 | $1,000 | $4,900 | |
$500,001 | $750,000 | $2,400 | $12,100 | |
$750,001 | $1,000,000 | $23,500 | $23,500 | |
NOTE1: The above rates and information is based on reality but is not reality, it’s simplified for the assignment. Banks have all kinds of varying terms and conditions to make it hard to compare one bank with another. the above table is not a reflection of reality; it’s a first-year assignment example.
The program must have
- A clear easy to use main menu with an exit
- Displays a table above based on the RatesIr1.txt file called “rates report 1”.
- Displays a table above based on the RatesIr2.txt file called “rates report 2”.
- It produces a report “First Home Buyer report” for a first home buyer of what they will repay each month including a line for stamp duty.
- It produces a ‘Investor report’ for an investor for a proposed purchase with a given rental. If the property is cashflow negative then this will be a negative number or it could be positive (unlikely in the act at this time for properties with a 20% deposit or less).
- It produces a ‘Investor Comparison Report’ for an investor for a list of proposed properties read from a designated input file (one of invRep1.txt, invRep2.txt, InvRep3.txt). It should identify the most profitable property. This report is worth only 2 points of the 25, so it’s optional.
- Note also that some input errors should be detected specifically:
- Bank codes must be in the BankIr file
- Cost of property must be between 150,000 and 1,000,000
- Loan type must be INV, HOME, HOME2, HOME3
- Deposit must be between 0 and the cost of the property
- The rent must be between $100 to $1000
- Inputs that are numeric must be checked and correctly processed if they do not contain numbers (e.g. an input of the word Fred).
- NOTE/WARNING – On my marking sheet test cases will check some of this editing
Calculation of First Home buyer repayments
Before we can calculate the repayments there are a few inputs needed:
- the cost of the property
- The bank
- The loan type (Home or Home2)
- The amount of deposit
Also, in the ACT a $7,000 grant is given to new home buyers; this needs to be added to the deposit (assume this program is for the ACT only).
We are ignoring stamp duty which is low for first home buyers
Step | Action | Notes |
1 | input and check The cost of the property | Range 150,000 to 1,000,000 |
2a | Input interest rate table
(1 for the interest rates in BankI1.txt) (2 for the interest rates in BankI2.txt) |
|
2b | input and check The bank code | WESTPAC, COMB, etc. |
3 | input and check loan type | HOME, HOME2, HOME3 |
4 | input and check amount of deposit | Range 0 to cost of property |
5a | Look up stamp duty | |
5b | Add 7000 to deposit to give final deposit | |
6 | Add loan establishment fee and stamp duty to cost of property giving amount needed | |
7 | Subtract final deposit from amount needed giving amount of loan | |
8 | Compute % being loaned
(amount of loan)/(cost of the property)*100
|
|
9 | Check that the loan is for less than or equal to the max % that can be borrowed | If not print a message and return to menu |
10 | Convert the % interest rate to a decimal | Eg 3.71% would become 0.0371 |
11 | Use the supplied formulae to find the monthly repayments | This is the method ‘calcMonthPayment’ |
12 | Display all the details – see example run | |
Example Calculation: (WESTPAC HOME 3.69% 395 80%)
Step | Action | Notes |
1 | input and check The cost of the property | 300,000 |
2a | Input interest rate table
(1 for the interest rates in BankI1.txt) (2 for the interest rates in BankI2.txt) |
1 |
2b | input and check The bank code | WESTPAC |
3 | input and check loan type | HOME |
4 | input and check amount of deposit | 50,000 |
5a | Look up stamp duty | 500 |
5b | Add 7000 to deposit to give final deposit | 57,000 |
6 | Add loan establishment fee and stamp duty to cost of property giving amount needed | 300,000+500+395
=300,895 |
7 | Subtract final deposit from amount needed giving amount of loan | 300,895 – 57,000
=243,895 |
8 | Compute % being loaned
(amount of loan)/(cost of the property)*100 |
243,895/300,000 = 0.81298
= |
9 | Check that the loan is for less than or equal to the max % that can be borrowed | 81.298 < 80 (false)
print an error message and return to menu |
10 | Convert the % interest rate to a decimal | |
11 | Use the supplied formulae to find the monthly repayments | |
12 | Display all the details – see example run |
Example Calculation: (WESTPAC HOME 3.69% 395 80%)
Step | Action | Notes |
1 | input and check The cost of the property | 300,000 |
2a | Input interest rate table
(1 for the interest rates in BankI1.txt) (2 for the interest rates in BankI2.txt) |
1 |
2b | input and check The bank code | WESTPAC |
3 | input and check loan type | HOME |
4 | input and check amount of deposit | 65,000 |
5a | Look up stamp duty | 500 |
5b | Add 7000 to deposit to give final deposit | 72,000 |
6 | Add loan establishment fee and stamp duty to cost of property giving amount needed | 300,000+500+395
=300,895 |
7 | Subtract final deposit from amount needed giving amount of loan | 300,895 – 72,000
=228,895 |
8 | Compute % being loaned
(amount of loan)/(cost of the property)*100 |
228,895/300,000 = 0.7629
= |
9 | Check that the loan is for less than or equal to the max % that can be borrowed | 76.29 < 80 (true)
|
10 | Convert the % interest rate to a decimal | 0.0369 |
11 | Use the supplied formulae to find the monthly repayments | -$1,052.27
|
12 | Display all the details – see example run |
Calculation of Investor Report
Before we can calculate the repayments there are a few inputs needed:
- the cost of the property
- The bank
- The loan type (Home or Home2)
- The amount of deposit
- The expected weekly rent
Also for cash flow purposes:
- The rent received is typically for 50 weeks (not 52 – this allows for 2 weeks of vacancy)
- 10% of the rent goes to the renting agent
- Roughly 4% of the rent goes on maintenance
- About 6% of the rent goes in land tax, rates and other holding costs
Step | Action | Notes |
First do the cost calculation | ||
1 | input and check The cost of the property | Range 150,000 to 1,000,000 |
2a | Input interest rate table
(1 for the interest rates in BankI1.txt) (2 for the interest rates in BankI2.txt) |
|
2b | input and check The bank code | WESTPAC, COMB, etc. |
(3) | Loan type will be INV | |
4a | input and check amount of deposit | Range 0 to cost of property |
5 | Input and check weekly rent | Range $100 to $1000 |
6a | Lookup the stamp duty | |
6b | Add loan establishment fee and stamp duty to cost of property giving amount needed | |
7 | Subtract final deposit from cost of the property giving amount of loan | |
8 | Compute % being loaned
(amount of loan)/(cost of the property)*100
|
|
9 | Check that the loan is for less than or equal to the max % that can be borrowed | If not print a message and return to menu |
10 | Convert the % interest rate to a decimal | Eg 3.71% would become 0.0371 |
11 | Use the supplied formulae to find the monthly repayments | This is the method ‘calcMonthPayment’ |
Now we do the Income Calculation | ||
12 | Take the weekly rent multiply by 50 giving gross rent | |
13 | Now multiply the gross rent by 0.8 giving gross income | 10%+4%+6% = 20%
100%-20% = 80% 80% >> *0.8 |
14 | Now divide the gross income by 12 giving monthly income | |
Now we do the Cashflow Calculation | ||
15 | Subtract the monthly repayments from monthly income to give monthly cash flow | |
16 | Display all the details – see example run | |
Example Calculation: (WESTPAC INV 3.61% 395 95%)
Step | Action | Notes |
1 | input and check The cost of the property | 400,000 |
2a | Input interest rate table
(1 for the interest rates in BankI1.txt) (2 for the interest rates in BankI2.txt) |
2 |
2b | input and check The bank code | WESTPAC |
(3) | Loan type input not needed will be INV | |
4a | input and check amount of deposit | 45,000 |
5 | Input and check weekly rent | $530 |
6a | Lookup stamp duty | 4,900 |
6b | Add loan establishment fee and stamp duty to cost of property giving amount needed | 400,000 +4,900+395
=405,295 |
7 | Subtract deposit from amount needed giving amount of loan | 405,295-45,000
=360295 |
8 | Compute % being loaned
(amount of loan)/(cost of the property)*100 |
360295/400000=.9007
|
9 | Check that the loan is for less than or equal to the max % that can be borrowed | .9007 < 0.95 (true) |
10 | Convert the % interest rate to a decimal | 0.0361 |
11 | Use the supplied formulae to find the monthly repayments | Calculated in Excel this is:
-$1,640.09 |
Now we do the Income Calculation | ||
12 | Take the weekly rent multiply by 50 giving gross rent | 530*50 = 26,500 |
13 | Now multiply the gross rent by 0.8 giving gross income | 26500*0.8 = 21,200 |
14 | Now divide the gross income by 12 giving monthly income | 21,200/12=1,766.66 |
Now we do the Cashflow Calculation | ||
15 | Subtract the monthly repayments from monthly income to give monthly cash flow | 1,766.66-1,640.09 = 126.57
Yep in this case you have a profit of $126.57 per month |
16 | Display all the details – see example run |
Notes
During my testing I found small rounding errors were affecting the result. Consequently, I will allow minor rounding errors in the answer (about 1cent).
The Excel PMT function can help in the creation of test data
The following formulae will give the repayments on a loan of $20,000 over 3 years at 5%
=PMT(0.05/12,3*12,20000) The correct answer is 599.42
This website seems to use the same formula as me (as detailed below) accurate to the nearest cent: It may help in testing.
The formula I used can be found on Wikipedia. Most students don’t need this level of detail but it’s here for the curious.
https://en.wikipedia.org/wiki/Amortization_calculator
double calcMonthPayment(double yearlyrate, double loan, int years)
{
/* Inputs to this routine are:
yearlyrate – the yearly interest rate as a decimal
(eg a 5% interest rate would be entered as 0.05)
loan – the amount of the loan in dollars and cents (eg 21210.90)
years – an integer indicating the years of the loan (eg 3 )
*/
double retv;
int payments;
double mul;
double rate;
rate = yearlyrate / 12;
payments = years * 12;
mul = Math.pow(1 + rate, payments);
retv = (loan * mul * rate) / (mul – 1);
return retv;
}
I provide some code as follows:
I provide a menu example which uses a do while loop and has two options A and B (as well as an exit)
The following code is how I input bank code
System.out.printf(“\nEnter Bank Id: “);
String ban = in.nextLine();
//ban=ban.trim().toUpperCase();// you may want this
This a redacted/deleted code fragment of how I input cost of property
System.out.printf(“\nEnter Cost Of property: “);
double cp;
try
{
cp = in.nextDouble();
}
catch (InputMismatchException e)
{
// … code redacted/deleted …
}
// … code redacted/deleted …
String temp = in.nextLine();
I give you this code so you can use it (i.e. it’s ok to copy and or modify the supplied code).
How to Get Started
This may look daunting but it’s not much more than MT1 (your MT1 code is a good starting point). If you need to get started then look at MT1 and follow the getting started part of that assignment – because this Assignment is very similar.
Marking Rubric
Marking (This assignment part is worth 25 marks).
Marks | Feature |
7 | Good test plan and evidence of testing |
6 | Your program code, accuracy, functionality and formatting |
1 | You used arrays |
1 | You built a class to hold interest and bank data or as part of the investor comparison report |
2 | You coded the investor comparison report |
2 | Reflection Report |
6 | Results of mandatory testing |
-2 | First mandatory test that’s wrong |
-1 | Subsequent mandatory tests wrong |
-1 to -3 | Program has non-fatal significant bug |
Maximum of 12 marks for assignment | Program fatally crashes or won’t compile or is basically not working |
Minimum of 13 marks for assignment | Program basically works and is acceptably documented with a test plan. |
-0.5 to -25 | Program is not a BlueJ project or is not a Zip file. My tutors are not responsible for converting your project from (insert your IDE here) to BlueJ. |
Late submission | 5% per day up to 1 week then a mark of 0
Watch the Canvas site for late class wide extensions that may be given |
Example Runs
Menu Exit
Rates Report R1
First Home Buyers
Investment Loan
Error Case: Borrowing is too high a percentage
Example ‘investor comparison report’
Error case: ANZ has no INV loan type
Partial Example: disallowed loan in the Investor comparison report
Error case: enter the word bozo instead of cost