how to calculate the precentage of calories that come from fat?

if for each gram of fat there is nine calories.