Assignment 3 - Buying and Selling a Stock

Due October 14th

This assignment will give you practice using cin and cout, working with strings, working with variables, performing calculations, and formatting output.

The program will simulate the purchase and sale of shares of stock using an initial investment of $10000.  Your program must adhere to the following specifications.
  1. The stock purchase must be made using the Open price on the first market day of 2019, that is, 01/02/19.
  2. You must purchase whole shares of stock using your $10000.  For example, if you purchase stock at $45.67 per share. you would purchase 218 shares and have $43.94 in cash left.  You will use the cash left in the determination of the gain.  For the gain, use the formula
    gain = value of shares sold + cash - initial investment
  3. The purchase date, stock ticker, and initial investment amount must be stored as named constants.  Store the dates and stock ticker as string type.
  4. You must prompt for the purchase price, sell date, and sell price.
  5. Make sure you match the output format shown in the sample below.  Include dollar signs, percent symbol, decimal precision, and line spacing as illustrated.

Sample Output

Note: This is phony data.  You do not have to use real data.
Enter the purchase price => 69.55
Enter the sell date (mm/dd/yy) => 10/09/19
Enter the sell price => 71

Stock Ticker: WMT

Purchase Date: 01/02/19
Purchase Price: $69.55
Number of Shares Purchased: 143

Sell Date: 10/09/19
Sell Price: $71.00
Value of Shares Sold: $10153.00

Gain: $207.35
Percent Gain: 2.1%
<=== User input


<=== Print text and string variable

<=== Print text and string variable



<=== Print text and string variable