If you don't post the current code and its output, how can anyone help you fix it?
Type: Posts; User: Norm
If you don't post the current code and its output, how can anyone help you fix it?
Post the new code and its output to show what is happening..
Move this line to just in front of where you print out the value of getTotalSold.
Have these two line right next to each other.
int getTotalSold = (s1.getNumSold() + s2.getNumSold() +...
You can not change the values used to compute a sum after you compute the sum.
for example
x = y+ z;
y = y = 2;
now x does not equal the current value of y + z because y has been changed/
Please Edit your post and wrap your code with
<YOUR CODE HERE> to get highlighting
You have used the wrong tags for the code.
What does the justSold() method do? Does it change any of the data...
My suggestion might not work if the class is in a package and the class files are not in the correct folders.
Open a command prompt window change directory to the folder with the class file and enter:
java <THECLASSNAME>
If Test is the class with the main() method:
Java Test
Can you use the java command to execute your program in a command prompt window?
The output you posted is from the IDE not from the java program.
Please copy and paste here the console from when you execute the program.
I see lots of println statements, some of them will print if the program executes.