Question
In c++ and with comments plaese SKILL SET: Working with Structures Your code MUST have PROPER INDENTING Your code INCLUDE COMMENTS For full credit, you
In c++ and with comments plaese
SKILL SET: Working with Structures
Your code MUST have PROPER INDENTING
Your code INCLUDE COMMENTS
For full credit, you must USE FUNCTIONS
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
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
Validation of number of shares and current/purchase price is optional. I will only test with valid data. Your program should make sure the menu option is valid (give a message if not), and that you do not overflow your array.
***USE FUNCTIONS to organize your code!
Main should have the loop to control the menu and calls to functions for each option:
For option1: two possibilities, choose one
addRecord needs the array and the next available position to add a new stock. Prompts for the data and adds the element to the array
or
createStock takes no input. Prompts for the data and returns a Stock object
For option 2:
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!)
SUBMIT TWO SEPARATE FILES:
LAB REPORT - FOLLOW THE TEMPLATE word pdf (includes all source code copied/pasted to the end of the document). DO NOT INCLUDE THIS IN YOUR ZIP FILE.
All your source code in a ZIP FILE
How to Submit Your Assignment
Your lab report should be a SINGLE WORD FILE (or pdf) with multiple pages.
Your code must be in a ZIP (compressed) file.
Make sure there are NO SPACES IN THE FILE NAME THAT YOU UPLOAD. PLEASE email me if you have any questions about this.
Submit your work here in the CANVAS system as a Word 97-2003, .docx or pdf file. Google docs also acceptable.
Directions to Submit
On the right hand Menu, you will see a SUBMIT ASSIGNMENT button with a white plus sign.
Click on the SUBMIT ASSIGNMENT Then click BROWSE to look for your file on your computer.
When done, click the SUBMIT ASSIGNMENT button.
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