Question: In addition, in the class containing Main() create several objects of the class, use the methods and output appropriately. C# programming Write the definition of


Write the definition of a class that has the following properties: a.


In addition, in the class containing Main() create several objects of the class, use the methods and output appropriately.

C# programming

Write the definition of a class that has the following properties: a. The name of the class is Stock. b. The class Stock has four instance variables: name of type String, previousPrice and closingPrice of type double, and numberOfShares of type int. c. The class Stock has the following methods: toString to retum the data stored in the data members with the appropriate titles as a string setName-method to set the name setPreviousPrice method to set the previous price of a stock. (This is the closing price of the previous day.) setClosingPrice method to set the closing price of a stock setNumberOfShare-method to set the number of shares owned by the stock getName-value-returning method to return the name getPreviousPrice-value-returning method to return the previous price of the stock getClosingPrice-value-returning method to return the closing price of the stock getNumberOfShare value-returning method to return the number of shares owned by the stock 544 | Chapter 8: User-Defined Classes and ADTS percentGain value-returning method to return the change in the stock value from the previous closing price and today's closing price as a percentage shareValues value-returning method to calculate and return the total values of the shares owned default constructor- the default value of name is the empty string ""; the default values of previousPrice, closingPrice, and numberOfShares are 0. constructor with parameters sets the values of the instance variables name, previousPrice, closingPrice, and numberOfShares to the values specified by the user d. Write the definitions of the methods and constructors of the class Stock as described in part c.

Step by Step Solution

3.41 Rating (151 Votes )

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 Programming Questions!