I see my problem now. Thanks
the code works, well sort of.
When it runs i get values like:
"Sum2 is greater
Final averages: gettinganestimate.Average@5f893efe, gettinganestimate.Average@2b86c6b2"
I've yet to understand why sum1 and sum2 aren't coming out right.
"getanestimate" is the name of the program.
Joined: Mar 19, 2011
This is hard to figure out without seeing the changes you made. Did you change the types of sum1 and sum2? If sum1 and sum2 are Average objects, you can't simply print them like that. Again, I'm just guessing here because I can't see your code.
Assuming you have made sum1 and sum2Average objects - e.g. something like this:(incidentally, having a variable called "sum" actually meaning "average" is very misleading - you should try and have variable names that match their actual meaning)
Then what you see is the default behaviour when you try and convert an object to a String (which is what happens when you print it out like that). If you're trying to print out the averages you've got two options.
1. Use the getAverage() method to get the actual value to print:
2. Override the toString() method to use the value you want. This is the method that is called whenever you convert an object to a String, and you can define the behaviour you want.
One other thing that springs to mind, that you may have already changed. I would expect that your getAverage() method would return a double, not an int - unless you want the average of 1 and 2 to be 1 instead of 1.5.
I just changed the part that was giving me the previous error. I created an "Average" method and clarified the issue with sum1 and sum2.
This issue with the output has been here for a while. what i posted is basically my code. sum1 and sum2 are both doubles.