////////
UPDATE: Christ! I had another look at the program, to see if I was being silly. And indeed I am. The error was in fact not a divide by zero error but 'ArrayIndexOutOfBoundsException:0' This is because because damageTaken is actually an array of values that stores many different 'damages'. So the equation I have is probably correct, and the problem I have now is entirely different from the initial title or question.
I'm giving the point to Thomas O for providing the apples analogy that perfectly answers the question of why.
Thank you so much for your input.
////////
Rest assured I have searched for an answer before asking this question:
In java I'm trying to create a progress bar. Our example: damage incurred, in a racing game, by setting the value for height as a percentage of maxmimum damage allowed before gameover.
At the start of the program damageTaken = 0;
(damageTaken / maximumDamage)
will give numbers between 0 - 1.
Then I just multiply that by the height of the progress bar, to create a fill bar of the appropriate height.
But of course, when damageTaken = 0 we are dividing by zero!!! So program crashes. And I want the progress bar to be of zero height!
why can't It just spit out 0 as the sum? And how do I get around this?