• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with my min and percentChange  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having problems with my min and percentChange working. I'm trying to print the min but I keep getting 0 and I also get 0 for the percentChange.






 
Ranch Hand
Posts: 30
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your nested loop calls initial.percentChange() and initial.totalValue(). You aren't assigning the return values of those two methods.

you could have it print out the values sum, arrayStock[i].getCurrentPrice(), and arrayStock[i].getNumShares in totalValue() to see what each is getting set to.

Also you are reseting the value of sum each time it loops in the for loop. perhaps you meant to use "+=" instead of "="?

I would have to test the code or inspect it more to see if there might be something else causing issues as well.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!