Create an application that tracks investments. Let the user type a ticker symbol into a text box, enter the number of shares, and set the purchase date. A sample is shown in Figure 1-23. In the example, the price per share was obtained from a data file that was read when the application started. The combo box contains a list of investment types.

When the user selects an investment type and clicks the Confirm button, the total pur- chase amount displays in the bottom right corner of the form. See image.

A ticker symbol is a short abbreviation that uniquely identifies the name of an invest- ment such as a stock. The term ticker refers to the noise made by ticker tape machines that were once used to print stock prices.

Implementation

Define a class named PriceType with two properties: Ticker (string), and Price (Double).

Define an enumerated type named InvestmentType that lists four types of investments: stock, mutual fund, commodity, and money market.

Define a class named Investment containing the following public properties:

  • Ticker symbol
  • Investment type
  • Purchase date
  • Price per share
  • Number of shares purchased
  • Purchase amount (read-only)

The class should contain a shared collection of PriceType objects. Also, create a shared method in the Investment class that loads PriceType information from a comma-delim- ited text file (in real life, we would expect these values to change constantly). Each line in the text file should look like the following, in which the first value is the ticker sym- bol, and the second value is the current price:

AMB, 32.2

The file should contain at least ten lines like this, each with a different ticker symbol and price.

Create a method in the Investment class that receives a ticker symbol and returns the price of the investment associated with that ticker symbol.

User Interface Notes

As the user begins to type the ticker symbol into a text box, the application should search for the symbol and display the price per share. As soon as the ticker symbol matches an existing symbol in the collection, the price should appear in a label on the form. We sug- gest that you write an event handler for the TextChanged event of the TextBox control. When the user clicks the Confirm button, its click handler should create an Investment object and initialize its properties with values in the controls on the form.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.