SENG6110 Programming Assignment 2 – Trimester 1, 2023
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
SENG6110 Programming Assignment 2 – Trimester 1, 2023
Due: By electronic submission (Canvas) by 11:59pm on Friday April 14.
Cryptocurrency Capital Gains Tax and Profit – Part II
Introduction
The objective of this assignment is to extend the implementation of Assignment 1 using arrays (as seen in weeks 9 and 10) and external files.
Before you start
Carefully read the specification below. Make sure you have all the information necessary to start the program. If you are uncertain of something, do not make assumptions. Post your questions to the discussion board forum named "assignment 2" and check it regularly.
Problem specification
The program will allow up to 5 users and each user will be able to have 2 investments. The program will have the following options:
• Add user
If the number of users is already 5, the program will say that it is not possible to add a user. If the number of users is less than 5, then the program will ask the following inputs:
• Name – name of the user.
• Annual salary for an entire year (this needs to be a positive number and different from zero; if not, the program will show an error message and ask the salary again).
• Resident - if the user is a resident or not.
• Buying price of the cryptocurrency (the buying price needs to be a positive number and different from zero; if not, the program will show an error message and ask the buying price again).
• Selling price of the cryptocurrency (the selling price needs to be a positive number and different from zero; if not, the program will show an error message and ask the selling price again). For this assignment we are assuming that the selling price is always more than buying price so this should be checked as well, otherwise an error message is shown and ask again for selling price.
• No of years cryptocurrency is held (this needs to be a positive integer and different from zero; if not, the program will show an error message and ask again).
• Delete user
The program will delete the user and will require user name for that and will display the message “the user is deleted” . If the name is not found, the program will display the message “the user does not exist” . It is not necessary to ask again.
• Display user
The program will ask the name of the user. If the name does not exist, show a message. If the name exists, then the program will display the following information of the User:
- Name
- Residency status
- Buying price
- Selling price
- CGT
- Actual Profit
- The remaining amount possible to be invested in the first year. The remaining amount possible to invest is actual profit less the amount already invested (in case the user already has an investment). For example, If the actual profit is $500, the user has one investment already investing $200 in the first year, then the remaining amount available to invest is $300.
- Each investment information, which will be (or no information in case user does not have any investments):
• Amount invested in year 1, year 2 and year3
• Yearly profit (already calculated in assignment 1)
• Display all users:
If it does not have any users, the program will display the message “no users” . If users exist, the program will display the following information of all users. The program will display the information sorted by name. You need to implement a sort algorithm.
User 1:
• Name:
• Resident:
• Annual Salary
• Actual Profit
• No investment (if the user does not have any investment) OR
• Number of investments:
User 2:
• …
• etc
• Add investment
The program will ask the name of the user. If the name does not exist, show a message. If the name exists, then the program will check if the user already has 2 investments. If it is 2, the program will show a message. If it is less than 2, then the program will ask
- Initial deposit - the amount of money that the user would like to invest in the first year (it is necessary to verify if this amount is feasible. If not, show an error message and ask again). To be considered a feasible amount, it should be less than the remaining amount available to invest. If not, ask again. For example, if the actual profit is $500, and the user has no investment, then the remaining amount available to invest is $500. If the actual profit is $500, and the user has one investment already investing $200 in the first year, then the remaining amount available to invest in the first year is $300.
- Yearly Investment amount as the additional amount of money that the user wants to invest in cryptocurrency for the next two years. User must provide two values here (the amount needs to be a positive number or zero; if not, the program will show an error message and ask it again).
- Cryptocurrency – the cryptocurrency that user chooses to invest in. You need to provide three options: Bestcoin, Simplecoin and Fastcoin (user must choose one of the options: otherwise the program will show an error message and ask again). The predicted profit rates for the three cryptocurrencies are shown in the following table:
Predicted Profit Rate |
||
Bestcoin |
Simplecoin |
Fastcoin |
18% |
12% |
15% |
• Display investment.
The program will ask the name of the user. If the name does not exist, show a message. If the name exists, then the program will ask the investment number (1 or 2, which is the first or second position in the array). If the investment does not exist, the program will display the message “the investment does not exist” . If not, the program is then expected to display a table with details of the yearly profit for the next three years. (already completed in Assignment 1).
• Delete investment
The program will ask the name of the user. If the name does not exist, show a message. If the name exists, then the program will ask the investment number (1 or 2, which is the first or second position in the array). If the investment exists, then the program will delete the investment and the program will display the message “the investment is deleted” . If the investment does not exist, the program will display the message “the investment does not exist” .
• Save in a file
The program will save in a file (txt format) the information of each user (the same information described in “show user” above) and each investment (the same information described in “display investment” above). If there are no users, the files should have “no users” . For each user, if the user does not have an investment, the file should have “no investment” .
• Exit. The program will end.
Program Requirements
There must be three classes:
Investment, User, CgtInterface.
1) The Investment Class (Investment.java file): The instance variables will be (at least):
• year1Deposit – double
• year2Deposit – double
• year3Deposit – double
• coinSelection -- int
You need to implement at least two constructors. One will be the default one, it will initialize the variables with 0 or “” . The second constructor will have the parameters year1Deposit, year2Deposit, year3Deposit and coinSelection. The class needs to have methods to change and access all instance variables. You will decide which will be the other methods to be implemented in this class.
2) The User Class (User.java file) The instance variables will be (at least):
• name – a String
• investAccount – one dimensional array of Investment objects (size 2)
• annualSalary – double
• buyingPrice – double
• sellingPrice – double
• years -- int
• resident -- boolean
It will hold the required instance data for a user and it will have suitable methods to access and modify the data for a user. You will decide which will be the other methods to be implemented in this class.
2) The CgtInterface Class (CgtInterface.java file).
The instance variables will be (at least):
• users – one-dimensional array of User objects (size 5)
• noUsers – the number of users (it will start with zero).
You will decide which methods will be implemented in this class.
This class will create the interface and will :
• Receive the inputs from user and show the outputs.
• Validate input (ie. Negative numbers etc).
Marks will be awarded for layout (including visual aspects (variable names, indentation) and structural aspects (variable scope, method usage)), documentation (comments), and the submission's ability to perform as specified. A more detailed marking schema is available on Canvas.
Interface : GUI
You need to implement GUI for Assignment 2 (worth 7 marks). Assignment 1 had TIO and you can still submit assignment 2 with TIO only, but you will lose those 7 marks. Notice that only CgtInterface class needs to be modified when you implement GUI interface.
What to submit
You should submit one compressed .zip file via the "Assignment 2" link on Canvas, which should have: Three .java files (Investment.java, User.java, CgtInterface.java). Do not include .class files in your submission.
Add your student name on the top of each Java file submitted.
/*Author: name
*Student No: XXXXXX
*Date: 02-03-2022
*Description:
*/
Late Penalty and adverse circumstances
Note that your mark will be reduced by 10% for each day (or part day) that the assignment is late. This applies equally to week and weekend days. You are entitled to apply for special consideration if adverse circumstances have had an impact on your performance in an assessment item. This includes applying for
an extension of time to complete an assessment item. See
https://www.newcastle.edu.au/currentstudents/learning/assessments-and-exams/adverse-circumstances
for more details.
In Canvas you will find a new forum in the discussion board: “assignment2” . Any question about the assignment 2 you can post there. Check this forum regularly.
2023-04-07