HW5: Design a class named Stock that contains a private string data named symbol for the stock's symbol. A private string data named name for the stock's name. A private double data named previousClosingPrice that stores the stock price for the previous day. A private double data named currentPrice that stores the stock price for the current time. A private static integer named numberCompany that stores the number of companies that have been created. Give the following modifiers as public in the class Stock: A constructor with arguments that creates a stock with the specified symbol, name, previous closing price, current price, and increases the numberCompany by one. The methods getSymbol, getName, getCurrentPrice, getPreviousClosingPrice, and getNumberCompany. The methods setSymbol, setName, setCurrentPrice, and setPreviousClosingPrice. One static method called getNumberCompany to return the number of companies that have been created.
Write a test program that creates Stock objects using a for-loop and an array with size 2.
1. The stock symbol is ORCL, the name is Oracle, and the previous closing price is 51.75. The new current price is 51.87.
2. The stock symbol is MSFT, the name is Microsoft, and the previous closing price is 114.45. The new current price is 114.26.
3. Then update the current price of MSFT to 114.50.
The following method headers are created in the test program:
public static Stock createStockObject(): returns an object
public static void displayStockObject(Stock stck): displays the object content
Display the stock symbol, stock name, previous price, current price (the prices should use two digits after the decimal point), and finally display the number of companies using getNumberCompany().