Question: A string data field named symbol for the stocks symbol. A string data field named name for the stocks name. A double data field named
- A string data field named symbol for the stocks symbol.
- A string data field named name for the stocks name.
- A double data field named previousClosingPrice that stores the stock price for the previous day.
- A double data field named currentPrice that stores the stock price for the current time.
- An integer data field named ID that stores the identifier number of stock.
- A constructor that creates a stock with the specified symbol, name, and ID.
- A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice
- Create a random object from the Random class (java.util.Random). We will use this object for the ID number of Stock between (0 to 100).
- Ask a user for the name and symbol of Stock. So, you should create two string variables in the test program.
- Create a Stock object with the stock symbol (from the user), the name of symbol (from the user), and ID (from Random object by using nextInt(100) method).
- Ask the user for the previous closing price and the current price. Note: Don't create two variables for them. You can use the Stock object to assign the values of these two variables from the user.
- Display the stock name, the stock symbol, the stock ID, and the pricechange percentage.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
