how to measure macronutrients both in grams and in calories?

I am trying to compose a diet to use a few times per year for short term semi-fasting over several low calorie days.
The diet parameters I need to follow set amounts of protein, fats and carbs as percentages of the total number of calories I'll eat on those days. When I enter foods in my diary the macro nutrients are specified in grams not calories. I will need to know how many calories there are of each macronutrient in order to achieve the specified percentages of total calories for the day.
I would so appreciate help in knowing how to do this. Thank you kindly.
forest moss

Answers