Copyright  © – Sudharsan Iyengar and Winona State University

 

CS-415            Pascal Assignment                             Due: Midnight - 3/26/2023

                       

A stock is first offered to the public at a start-off stock-price. The initial offering also comes with an initial volume (or number of stocks). Every stock is identified by a stock symbol – which is a string. Then, the stock market takes over and the stock-price fluctuates with the buying and selling of the stock.

 

Read in an input file of stocks – stocks.txt with initial stock values (name, volume, price) for 5 stocks. The broker has initial cash in hand - $10000.

 

Create a menu to enable the broker to select and buy or sell stocks, view current state, and exit. Note – you cannot buy more that available stocks and cannot spend more that you have towards buying. Similarly, you cannot sell more than what you have.

 

Write a Stock record with procedures for storing stock symbol, an initial volume, and an initial stock-price, and procedures for -

 

            Buy                 Select a stock

then - number, new price

            decreases the volume by number and sets the stock-price to

the new price

            Sell                  select a stock

Then - number, new price

increases the volume by number and sets the stock-price to

 the new price

 

            CurrentState   Prints the current state of all the stocks – volume and price, and total value of the stock

                                    Then prints the current portfolio of the broker

                                                The stocks held by broker, and cash in hand.

 

            Exit                 Exit the application.