Question: Design a class named Stock that contains: A string data field named symbol for the stock's symbol. A string data field named name for the

Design a class named Stock that contains:

  1. A string data field named symbol for the stock's symbol.
  2. A string data field named name for the stock's name.
  3. A double field named a previous closing price that stores the stock price for the previous day.
  4. A double data field named a current price that stores the stock price for the current time.
  5. A constructor that creates a stock with a specified symbol and name.
  6. A method named getChangePercent() that returns the percentage changed from previous closing price to currentPrice.


Draw the UML diagram for the class. Implement the class. Write a test program that creates a Stock object with the stock symbol JAVA, the name Sun Microsystems Inc, and the previous closing price of 4.5. Set a new current price to 4.35

Step by Step Solution

3.37 Rating (141 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To design the Stock class as described and to write a test program well follow these steps Step 1 Draw the UML Diagram plaintext Stock symbol String n... View full answer

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!