In this program you will make suggestions as to what stock to buy among the ones that are owned. There is a file named stocks.dat. Copy this file into your directory.
Each line of the file has four values on it. The first is the stock symbol. The second is the number of shares owned. The third value is the current price of the stock. The fourth and last is the buying price for the stock. When you read these values in you are to store these values in an array for each of the types of values (4 arrays). You will have an array for the stock symbol, an array for the number of shares owned, an array for the current price of the stock, and finally an array for the buying price of the stock.
Once you have the values read into the arrays you are to find stocks that may be possible “buy” candidates. A buy candidate is defined as follows:
The number shares owned must be less than 100 shares.
The current price of the stock should be less than or equal to the buying price of the stock.
The output of this program should be as follows:
Stock Symbol Current Price Bought Price Shares Owned
=========== =========== ========== ===========
MSFT 18-3/4 21-3/4 55
AAPL 572-1/2 800 75
And so on for as many stocks that you can find that meet the criteria above.
Please note you must display the stock price as a whole number followed by a fraction as shown above. For example, if the current stock price is 18.25, this would be displayed as 18-1/4. You must convert any fractional part to its equivalent whole fraction.
All of the tasks in this program should be carried out in functions. The main function should consist of calls to functions only. You cannot use GLOBAL variables. Any information that needs to be passed between functions should be either pass-by-value or pass-by-reference (if you need to change the value).
Both of the variables in the last line share their names with parameter names. That means that these local variables will be used in this section of the code, not the parameters, which is probably not what you want.
Also have you learned about structures or classes? Using a structure or class to hold all the variables you will read from the file will make things much easier.