Please go back and check the question again. What you wrote simply doesn't make sense.
Start by naming things. Let "x" be the numer of candybars in the box, let "y" be the number of 'good' candy bars in the box.
9/10 of the candy bars in the box are good. so y= (9/10)x. If one 'good' candy bar is taken, there are x- 1 candy bars left and y- 1 'good' candy bars left.
I suspect your last sentence is clearly incorrect. Saying that "it's only 8/10 of the good candy bars left in the box" means that now, the number of good candy bars is 8/10 of what there were before: y- 1= (8/10)y which is the same as (2/10)y= 1, y= 5. But that would give 5= (9/10)x so x= 50/9 which is not a whole number. Taking one good candy bar would leave 41/9 good candy bars and 9/10 bad for a total of 50/9 cfandy bars left in the box. But I don't believe there were fractional candy bars in the box.
But if what was intended was "the good candy bars left are now 8/10 of the bars left in the box." That is, y-1= (8/10)(x- 1). Solve the two equations y= (9/10)x and y- 1= (8/10)(x- 1). Subtracting the second equation from the first will immediately eliminate y.
Now, y- (y-1)= 1 and (9/10)x- ((8/10)(x-1))= (9/10- 8/10)d+ 8/10= (1/10)x+ 8/10 so the equation becomes (1/10)x+ 8/10= 1 or (1/10)x= 2/10 so that x= 2. That is two whole candy bars but what could "9/10) of them are good" mean? That would appear to mean that 2/10 of a candy bar was "not good" while 1 and 8/10 candy bar was "good"! Taking the one entirely good candy bar would leave one candy bar that is 8/10 good and 2/10 bad meeting the second requirement. But how in the world is a candy bar 8/10 "good" and 2/10 "not good"?
It would make far more sense to say that 9/10 of the candybars were good and, after taking one "good" candy bar, 7/9 of the remaining bars were good. Then one would get that there were 10 candy bars in the box, 8 of them good, 2 not good. Taking one good candy bar would leave 9 candy bars, 7 of them good.