Question: in java Design and implement class Stock to represent a companys stock. The class defines the following attributes (variables) and methods: 1. A class (Changed
in java Design and implement class Stock to represent a companys stock. The class defines the following attributes (variables) and methods: 1. A class (Changed from private) variable of type String named Symbol for the stocks symbol. 2. A class (Changed from private) variable of type String named Name for the stocks name. 3. A class (Changed from private) variable of type double named previousClosingPrice to store the last closing price. 4. A class (Changed from private) variable of type double named currentPrice to store the current price. 5. A constructor method to create a stock with user-specified name and symbol. 6. Method getName() that returns the stocks name. 7. Method getSymbol() that returns the stocks symbol. 8. Method setClosingPrice() that sets the previous closing price. 9. Method setCurrentPrice() that sets the current price. 10. Method getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice. Using the formula: -(previousClosingPrice - currentPrice) / previousClosingPrice * 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
