You will be building aStock Portfolio Applicationthat allows you to do transactions like buying and selling stocks and ability to deposit and withdraw cash from your brokerage account.
You will create aTransactionHistoryclass with the following attributes (25 points):
Private field
|
Purpose of this field
|
String ticker
|
Will store ticker of the Stock or CASH
|
String transDate
|
Date when the transaction occurred
|
String transType
|
Type of transaction BUY/SELL for stock, DEPOSIT/WITHDRAW for CASH
|
double qty
|
Quantity for the transaction
|
double costBasis
|
Cost Basis of stock. For CASH this will be 1.00
|
Create the
- constructor – Default and Overloaded constructor
- Getter and Setter methods for all the attributes.
You will create another class calledPortfolioManagerthat will have themain methodto test the application. This will have the following attributes
Private field
|
Purpose of this field
|
ArrayList portfolioList = new ArrayList();
|
ArrayList to store any number of TransactionHistory records
|
You will create a menu for user to enter different types of transactions such as
- DEPOSIT Cash
- WITHDRAW Cash
- BUY Stock
- SELL stock
Create a menu as shown below to do the different types of transactions and display Transaction History and Portfolio Information.
Brokerage Account
0 - Exit
1 - Deposit Cash
2 - Withdraw Cash
3 - Buy Stock
4 - Sell Stock
5 - Display Transaction History
6 - Display Portfolio
Enter option (0 to 6):
Things to consider:
- Make sure to put header comments for each of the java file.
- Make sure that you get an error message when invalid input is entered from the menu.
- Four Transaction Type – BUY, SELL, DEPOSIT, WITHDRAW
- Make cost basis for CASH transaction as 1.00.
- The CASH transactions are automatically created while buying or selling stock.
- When CASH is withdrawn, qty is negative and when deposited qty is positive
- Make sure to check if you have enough CASH in the bank to purchase stock.
- Withdrawl amount cannot be more than the CASH available in the account (Give an error message).
- When buying or sell stocks, create two transactions, the stock is purchased or sold, and other transaction of CASH withdrawn or deposited in the account.
Hint:
- UseArrayListto create Transaction History.
- Loop through the transaction historyArrayListto generate the Portfolio information
TEST CASES
Thehighlightedinformation is entered through the menu.
- Buying 100 stock DFEN after an initial deposit of $10000 CASH is made in the account. The cost of each DFEN stock is $15
The Transaction History will display
Ashish GulatiBrokerage Account
===============================
Date Ticker Quantity Cost Basis Trans Type
==================================================================
7/1/2022 CASH 10000.0 $1.0 DEPOSIT
9/20/2022 DFEN 100.0 $15.0 BUY
9/20/2022 CASH -1500.0 $1.0 WITHDRAW
The Portfolio will display
Portfolio as of: 12/06/2022 15:38:16
====================================
Ticker Quantity
=================
CASH 8500.0
DFEN 100.0
- Buying and selling of stock DFEN after an initial deposit of $10000 CASH is made in the account. 100 stocks of DFEN are bought at $15 and laterALLthe stocks are sold at $19, making a gain of $400 so the CASH in the portfolio increased $10400.00
The Transaction History will display
Ashish Gulati Brokerage Account
===============================
Date Ticker Quantity Cost Basis Trans Type
==================================================================
7/1/2022 CASH 10000.0 $1.0 DEPOSIT
9/20/2022 DFEN 100.0 $15.0 BUY
9/20/2022 CASH -1500.0 $1.0 WITHDRAW
11/22/2022 DFEN 100.0 $19.0 SELL
11/22/2022 CASH 1900.0 $1.0 DEPOSIT
The Portfolio will display
Portfolio as of: 12/06/2022 15:38:16
====================================
Ticker Quantity
=================
CASH 10400.0
- Buying and selling of stock DFEN after an initial deposit of $10000 CASH is made in the account. 100 stocks of DFEN are bought at $15 and later50stocks are sold at $19, making a gain of $200 so the CASH in the portfolio increased $10400.00. Then $2000 is withdrawn from the bank.
The Transaction History will display
Ashish Gulati Brokerage Account
===============================
Date Ticker Quantity Cost Basis Trans Type
==================================================================
7/1/2022 CASH 10000.0 $1.0 DEPOSIT
9/20/2022 DFEN 100.0 $15.0 BUY
9/20/2022 CASH -1500.0 $1.0 WITHDRAW
11/22/2022 DFEN 50.0 $19.0 SELL
11/22/2022 CASH 950.0 $1.0 DEPOSIT
11/23/2022 CASH -2000.0 $1.0 WITHDRAW
The Portfolio will display
Portfolio as of: 12/06/2022 15:38:16
====================================
Ticker Quantity
=================
CASH 7450.0
DFEN 50.0
Grading Criteria
CreatingTransactionHistoryclass(25 marks)
Creating Menu to accept valid inputs and creating different types of transactions(25 marks)
Display Transaction History and Portfolio Information(25 marks)
Meets all the coding and testing requirements(25 marks)
Submission
Please make sure to submit the below files inzip format.
- Both the java files
- Screen snapshot of your program running in Word document
- Please check the due date.No extensionafter the due date.