No time now to read the code, but...
the message is clear - you have used double where an int is required. The compiler won't allow an automatic conversion because doubles can have fractional values but ints can't.