Calculations using only integers causes the end result to be integer, even if later you assign it to a floating point value like double. Integer division works by counting how many times the denominator can fit entirely in the numerator.
To resolve, you have to cast at least one of the 2 operands in the division so that the division is performed already in double precision (numbers inside arithmetic operations are automatically casted to a type that allow greater precision than its operands, if at least one of the operands have that precision):
average = (double)likes / total;
or
average = likes / (double) total;
Please note that this is different than average = (double) (likes / total);
, which would cast the result after it has already been rounded down.