calculate costs