Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ In this project, you will write a program to manage a bank account and a stock portfolio. The program will be written using inheritance

C++

In this project, you will write a program to manage a bank account and a stock portfolio. The program will be written using inheritance structure for the classes. Starting with the abstract base class Account, write two derived classes stockAccount and bankAccount. All of the accounts should be linked together through the common cashBalance variable. The starting balance for the account will be $10000. The balance will change as you perform the transactions

In the main menu, you can select to work with either stock account, bank account, or exit the program. The sub menu for each will be as following:

Stock account:

- Display current price for a stock symbol

- Buy stock

- Sell stock

- Display current portfolio

- Display transactions history

- Return to main menu

Bank account:

- Display current cash balance

- Deposit to account

- Withdraw from account

- Display transactions history

- Return to main menu

1. Stock Account. This program manage your stock portfolio. You can purchase or sell stocks. Use the stock information in stock1.txt files for all of the transactions. When you initiate a transaction, you can randomly select one of the files for stock prices.

stock1.txt:

image text in transcribed

2. Display current price for a stock symbol. This function take the symbol of a stock and display its current price. The current price will be the price of one of the stock file selected randomly. The format as follow:

VNET 21Vianet Group Inc. ADR 5.48 12:48:53

If the stock is not available, display corresponding message.

3. Buy stock. You can purchase the stock by enter the symbol, the amount of share you want to buy, and the price youre willing to pay for each share. This function will first select a random stock file. This selected stock file will provide the symbol name and the price for each stock. Assume that the number of available shares is unlimited. If the price youre willing to pay for each stock is large or equal to the current price, the transaction will be performed (given that you have enough cash in your account balance). If the price youre willing to pay less than the current price then the transaction will not go through. Display a corresponding message (Cannot process transaction). Update your account balance and stock portfolio after each transaction.

4. Sell stock. You can sell the stock by enter the symbol, the amount of shares you want to sell, and the price youre willing to sell for each share. This function will first check your stock portfolio to see if you have the stock and the shares you want to sell. Next, the function selects the random stock file for checking the current stock prices. If the price youre willing to sell for each stock is less than or equal to the current price, the transaction will be performed. If the price youre willing to pay larger than the current price then the transaction will not go through. Display a corresponding message (Cannot process transaction). Update your account balance and stock portfolio after each transaction.

5. Display current portfolio:. This function displays the current account balance and the stock portfolio. The function first select a random stock file for current prices. The format as follow:

Cash balance = $12034.54

Symbol Company Number Price Total

VNET 21Vianet Group Inc. ADR 120 5.48 657.60

AGTK Agritek Holdings Inc. 3000 0.02 60.00

Total portfolio value: $ 12752.14

6. Display transactions history. This function displays the stock transaction history. For every transaction, the information should be saved in stock_transaction_history.txt file. This function will read the stock_transaction_history.txt file to display all the the transaction history. The format as in following

Action Symbol Shares Price Time

Buy VNET 20 5.48 13:30:45

Buy AGTK 130 0.02 13:34:54

Sell AKAM 100 58.88 14:34:23

7. Return to main menu: this function returns to the main menu

8. Display current cash balance. This function can reuse the Display current portfolio function. The format as in following:

Cash balance = $12034.54

Symbol Company Number Price Total

VNET 21Vianet Group Inc. ADR 120 5.48 657.60

AGTK Agritek Holdings Inc. 3000 0.02 60.00

Total portfolio value: $ 12752.14

9. Deposit to account. This function deposit money to your account. Enter the amount to be deposited and update your account. Display corresponding message if the amount is not correct, Invalid input, (negative amount, not a number, etc.). You can reuse the Display current portfolio function to update the account. The format as in following:

Deposit $500.00 to bank account

Cash balance = $12534.54

Symbol Company Number Price Total

VNET 21Vianet Group Inc. ADR 120 5.48 657.60

AGTK Agritek Holdings Inc. 3000 0.02 60.00

Total portfolio value: $ 13252.14

10. Withdraw from account. This function withdraw cash from your account. Enter the amount to be withdrawn and update your account. Display corresponding message if the amount is not correct, Invalid input, (negative amount, amount more than available cash, not a number, etc.). You can reuse the Display current portfolio function to update the account. The format as in following: Deposit $500.00 to bank account

Cash balance = $12034.54

Symbol Company Number Price Total

VNET 21Vianet Group Inc. ADR 120 5.48 657.60

AGTK Agritek Holdings Inc. 3000 0.02 60.00

Total portfolio value: $ 12752.14

11. Display transaction history. This function display all of the bank transaction history. For every transaction, the information should be saved to bank_transaction_history.txt file. This function will read the bank_transaction_history.txt file to display all the the transaction history. The format as in following:

Action Amount Cash Balance Date Time

Deposit 500 12534.54 04/14/2017 01:48:19

Withdraw 500 12034.54 04/14/2017 01:48:33

Notes: Use a vector to manage the current list of stocks. Sort the list for every stock transaction. The list is sorted by the stock symbol. Reuse all the functions and variables as much as possible through inheritance and polymorphism. Each function will check for the current stock prices by selecting a new random stock file if needed.

21Vianet Group Inc ADR VNET AGTK Agritek Holdings Inc AKAM Akamai Technologies Inc BIDU Baidu Inc ADR BCOR Blucora Inc. WIFI Boingo Wireless Inc. CARB Carbonite Inc. JRJC China Finance Online ADR CCIH Chinacache International ADR CCOI cogent Communications Inc. CXDO Crexendo Inc., EDXC ENDExx Corp. ENV Envestnet Inc. Facebook Inc. Cl A FB GDDY GoDaddy Inc Cl A IAC/InterActiveCorp IAC IIJI Internet Initiative Japan ADR INAP InterNAP Corp IPAS iPass Inc. JCOM j2 Global. Inc. Limelight Networks Inc. LLNW MOMO Momo Inc ADR NTES Netease Inc. ADR. EGOV NIC Inc. NO Mobile Inc. ADR NO OPESY opera Software ASA ADR. BLNKF Rhythmone PLC NAME Rightside Group Ltd. Sify Technologies Ltd. ADR Sina Corp SIFY SINA. SOHU Sohu.com Inc. SNST Sunset Capital Assets Inc. TCTZF Tencent Holdings Ltd TCEHY Tencent Holdings Ltd ADR TMMI TMM Inc. 55 0.02 58.82 173.31 17 13.68 9.3 2.92 45 44.4 45 0.05 33.5 41 42 36.88 75.05 8.8 3.35 28 83.2 2.49 38.4 266.22 20.5 3.63 10 9.29 0.88 69.64 39.43 0.51 29.85 29 77 0.06 21Vianet Group Inc ADR VNET AGTK Agritek Holdings Inc AKAM Akamai Technologies Inc BIDU Baidu Inc ADR BCOR Blucora Inc. WIFI Boingo Wireless Inc. CARB Carbonite Inc. JRJC China Finance Online ADR CCIH Chinacache International ADR CCOI cogent Communications Inc. CXDO Crexendo Inc., EDXC ENDExx Corp. ENV Envestnet Inc. Facebook Inc. Cl A FB GDDY GoDaddy Inc Cl A IAC/InterActiveCorp IAC IIJI Internet Initiative Japan ADR INAP InterNAP Corp IPAS iPass Inc. JCOM j2 Global. Inc. Limelight Networks Inc. LLNW MOMO Momo Inc ADR NTES Netease Inc. ADR. EGOV NIC Inc. NO Mobile Inc. ADR NO OPESY opera Software ASA ADR. BLNKF Rhythmone PLC NAME Rightside Group Ltd. Sify Technologies Ltd. ADR Sina Corp SIFY SINA. SOHU Sohu.com Inc. SNST Sunset Capital Assets Inc. TCTZF Tencent Holdings Ltd TCEHY Tencent Holdings Ltd ADR TMMI TMM Inc. 55 0.02 58.82 173.31 17 13.68 9.3 2.92 45 44.4 45 0.05 33.5 41 42 36.88 75.05 8.8 3.35 28 83.2 2.49 38.4 266.22 20.5 3.63 10 9.29 0.88 69.64 39.43 0.51 29.85 29 77 0.06

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions