Question: Using visual studios C# be sure I can copy and paste Exercise #2 : Design and implement class Stock to represent a companys stock. The

Using visual studios C# be sure I can copy and paste Exercise #2: Design and implement class Stock to represent a companys stock. The class defines the following attributes (variables) and methods: 1. A class variable of type String named Symbol for the stocks symbol. 2. A class variable of type String named Name for the stocks name. 3. A class variable of type double named previousClosingPrice to store the last closing price. 4. A class variable of type double named currentPrice to store the current price. 5. A constructor method to create a stock with user-specified name and symbol. 6. Method getName() that returns the stocks name. 7. Method getSymbol() that returns the stocks symbol. 8. Method setClosingPrice() that sets the previous closing price. 9. Method setCurrentPrice() that sets the current price. 10. Method getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice. Use the formula: (currentPrice - previousClosingPrice)/ currentPrice * 100 11. Method named toString() (Java & C#) or ___str___() (Python) to printout a meaningful description of a stock object when passing the object name to the print statement. e.g.: The statement PRINT yahooStock would print the string: Yahoo stocks closing price is $234.54. Now design and implement a test program to create two stock objects: one for Google with symbol GOG and the second is for Microsoft with symbol MSF. Set their closing and current prices according to the information below. Next, test the class methods on each object to print in the information in a similar manner to the one shown below:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!