We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
But your specific problem is simple:
"whenever the grams is 000,it throws an error."It will - division by zero generates a result that can't be stroed in a computer, so it generates a "devision by zero" exception. So check first:
double kilos = 0.0;
if (grams != 0)
{
kilos = grams / 1000;
}