Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Purpose Purpose of this homework is to write your first class, the Stock class.

ID: 3743442 • Letter: P

Question


Purpose Purpose of this homework is to write your first class, the Stock class. The Stock class You will implement a class named Stock. A stock has a String named symbol for the stock's symbol, and a double named price for the stock's current price. For example Apple stock's symbol is AAPL, price is 226.10 at this writing. Write a constructor with 2 parameters/arguments public Stock(String symb, double currentPrice) and methods: public String getSymbolo public double getPrice0 public void changePrice(double byPercent) These methods return the symbol and price, and change the stock's price by a certain percentage. Note that the percentage can be + or -for a price change up or down. The Tester class A Tester class is given to you to run your code. You may not alter Tester in any way. Study Tester carefully, it will help as you write Stock.

Explanation / Answer

public class Stock { private String symbol; private double price; public Stock(String symbol, double price) { this.symbol = symbol; this.price = price; } public String getSymbol() { return symbol; } public double getPrice() { return price; } public void changePrice(double byPercent) { price += price*(byPercent/100); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote