Calculate sum of products in LibreOffice Calc
Libreoffice calc has the sumproduct() function. If you name the ranges of the grade and cp columns (as described here), you can simplify the formula to =sumproduct(grade,cp)/sum(cp)
.
The easiest way would be to add an extra (hidden) column with the product and sum that column.