Can't find the right coding for calculation - URGENT!

Thanks a lot for your reply Mike, very much appreciated!

What you describe makes a lot of sense to me, but the problem is that I don’t really know what code functions I have to use for this (as I am far from a professional when it comes to this).

Could you possibly help me with this by translating your reply to code language (more or less)?

Thanks a lot!