Im working on a program that uses a class of stocks. one of the methods should calculate the current value of the stock. the instructions say "number of shares times current price". i have a method that updates the price by multiplying this current value by a random percentage. after running the program the value returned by getCurrentValue would be the same as the initial value, that is it never changes. i then changed the variable of currentPrice to static and now the value of currentValue changes but the answers it returns is really high. something along the lines of 3.7E18. having initially set up the currentPrice to 100.
is there something wrong in my code or maybe the instructions are wrong? i don't really know how stocks are valued.
heres some of my code:
private static double currentPrice;
public void updatePrice(){
double multiplier = 1.05 + new Random().nextGaussian() * 0.25;
currentPrice = getCurrentValue() * multiplier;
}
public double getCurrentValue(){
double currentValue = numShares * currentPrice;
return currentValue;
}