• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Help with my min and percentChange

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
Netbeans IDE Chrome Java
  • 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.
Oh the stink of it! Smell my tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic