Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started