In addition, in the class containing Main() create several objects of the class, use the methods and
Fantastic news! We've Found the answer you've been seeking!
Question:
In addition, in the class containing Main() create several objects of the class, use the methods and output appropriately.
C# programming
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
University Physics with Modern Physics
ISBN: 978-0133977981
14th edition
Authors: Hugh D. Young, Roger A. Freedman
Posted Date:
Students also viewed these programming questions
-
Portions of the financial statements for Avatar Technologies are provided below. Net sales Expenses: AVATAR TECHNOLOGIES Income Statement For the Year Ended December 31, 2024 Cost of goods sold...
-
Objects A, B, and C are moving as shown in Fig. E8.3. Find the x- and y components of the net momentum of the particles if we define the system to consist of (a) A and C, (b) B and C, (c) all three...
-
Several methods of translating foreign currency transactions or accounts are reflected in foreign currency financial statements. Among these methods are the current noncurrent, monetary nonmonetary,...
-
An increase in investment increases consumption in the short run, has no effect on consumption in the long run, and has an ambiguous effect on consumption in the Solow model of the very long run,...
-
Big Lots is the largest closeout retailer in the United States. Locate the consolidated income statement s filed in the 10-K of Big Lots, Inc. for year-end February 3, 2007, and February 2, 2008...
-
The force in an electrostatic field given by f(x, y, z) has the direction of the gradient. Find f and its value at P. f = xy, P: (-4, 5)
-
Figure 11.65 presents the PFD of a process for the recovery of methane from a feed stream consisting of \(75 \%\) methane and \(25 \%\) nitrogen. The process feed is first cooled from 90 to...
-
A process has the transfer function, where K has a nominal-value of K = 1. PID controller settings are to be calculated using the Direct Synthesis approach with ?c = 5 min. Suppose that these...
-
Compute uxxx for u(x, t) 8 sech (2x-t). = (Use symbolic notation and fractions where needed.) Uxxx = 512 tanh (2x-t) sech (2x t) Incorrect
-
The complexity and uniqueness of the federal government make it difficult to conduct a meaningful analysis of its financial condition. However, conducting a financial statement analysis does provide...
-
Discuss the capital structure of Southwest Airlines. Outline the most recent year's debt, equity, and total capital to show the overall capital structure of the corporation. Articulate the...
-
Pistol Corporation purchased 100 percent ownership of Scope Products on January 1, 20X6, for $56,000, at which time Scope Products reported retained earnings of $10,000 and capital stock outstanding...
-
Why has a human activity system more than one purpose?
-
Luca Pacioli is setting up a new business. Before actually selling anything, he bought a van for 13,000, a transportable market stall for 1,050; a computer for 450; and an inventory of goods for...
-
Evaluate each expression in Problems 3-32. \(\left(\begin{array}{l}9 \\ 1\end{array}ight)\)
-
The transfer function of a system is \(\frac{10}{1+s}\). When operated as a unity feedback system, the steady state error to a unit step input will be: (a) zero (b) \(1 / 11\) (c) 10 (d) infinity
-
This simulation is a simplified version of an experiment done by Robert Milliken in the early 1900s. Hoping to learn more about charge, Milliken sprayed slightly ionized oil droplets into an electric...
-
As water moves through the hydrologic cycle, water quality changes are common because of natural phenomena or anthropogenic pollution. Using Figure 11.1, describe how water-quality changes occur...
-
You are a mechanical engineer working for a manufacturing company. Two forces, F 1 (vector) and F 2 (vector), act on a component part of a piece of equipment. Your boss asked you to find the...
-
When a Dodge Viper is at Elwoods Car Wash, a BMW Z3 is at Elm and Main. Later, when the Dodge reaches Elm and Main, the BMW reaches Elwoods Car Wash. How are the cars average velocities between these...
-
In a popular and amusing science demonstration, a person inhales helium and then his voice becomes high and squeaky. Why does this happen? (Warning: Inhaling too much helium can cause unconsciousness...
-
If a pattern is used to model an overly broad portion of a system, the generality of resulting pattern is sacrificed. Explain with the help of an example.
-
Explain why a pattern representing rental system will not be complete and accurate.
-
What are the key characteristics of a model that makes it easily testable?
Study smarter with the SolutionInn App