Question
in C++ and with comments please PROBLEM: Create a menu driven application to keep track of your stock portfolio. Create a structure called StockInfo that
in C++ and with comments please
PROBLEM: Create a menu driven application to keep track of your stock portfolio. Create a structure called StockInfo that holds:
Company name
Number of shares
Purchase price
Current price
The current value of a stock is calculated as:
Number of shares * (current price purchase price)
Create an array in main that can hold a maximum of 10 StockInfo objects.
Your program will have the following menu options:
1-Add Stock
2-Display Profit/Loss
3 Exit Program
For option 1
Prompt the user for info to add one new stock to the array:
Enter company name: Amgen
Number of shares? 200 50.75
Purchase price? 50.75
Current price? 75.625
Make sure there is room in the array if it is full, give a message to the user.
Otherwise, store in the next available position.
For option 2
Display a report based on all the stocks in the array as shown below:
Portfolio Report ================ Company Profit(Loss) Amgen $ 4975.00 Delta $ -1450.00 Total value $ 3525.00
Data validation is optional. I will only test with valid data.
***USE FUNCTIONS to organize your code!
Main should have the loop to control the menu and calls to functions for each option:
addRecord needs the array and the next available poosition to add an element
displayReport needs the array and the number of ACTUAL items used in the array
You should code and test one function at a time!
Testing show one run with THIS DATA, and another with data OF YOUR OWN
use option 1 to add a stock
Company shares purchase current
Amgen 200 50.75 75.625
use option 1 to add a stock
Delta 100 111.75 97.25
Option 2 to show report
Option 1 three more times to add these stocks
Company shares Purchase Current
Cisco 400 22.00 16.50
Intuit 250 38.00 44.50
ToysRUs 300 15.90 17.95
Option 2 for report
Quit
(You should make sure the results are correct!)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started