I'm working on an ASCII version of battleship, and as part of the project, the hit/miss stats have to be printed out at the end. Because this is for a computer science course, my output has to be identical to the required output.

My program prints this:
Hit ratio: 66.66666666666667%
When it should be printing:
Hit ratio: 66.66666666666666%

and..
My Program:
Hit ratio: 33.333333333333336%
Required output:
Hit ratio: 33.33333333333333%

I'm assuming that this is happening because of the way doubles behave, but I have no idea how I would fix that.
Here's the code that computes the ratio:

double ratio = 100.0 * numHit / numFired;
Where numHit is a double representing the number of missiles that hit
and numFired is a double representing the number of missiles fired