Question 1184544
Let x =  # of carrot cakes, y = # of cheese cakes, and z = # of chocolate cakes.


===> The system is {{{system(matrix(3,1, x+y+z = 21, 10x+20y+15z = 320, z = 2x+2y))}}}, or {{{system(matrix(3,1, x+y+z = 21, 2x+4y+3z = 64, 2x+2y-z=0))}}}, or   {{{(matrix(3,3, 1,1,1,2,4,3,2,2,-1))*(matrix(3,1,x,y,z)) = (matrix(3,1, 21,64,0))}}}  equivalently.


===> {{{(matrix(3,1,x,y,z)) = (matrix(3,3, 1,1,1,2,4,3,2,2,-1))^(-1)*(matrix(3,1, 21,64,0))}}}.


I now refer you to https://www.emathhelp.net/calculators/linear-algebra/inverse-of-matrix-calculator/, 
where the inverse of the above matrix can be calculated with all steps shown.


===>  {{{(matrix(3,1,x,y,z)) = (matrix(3,3, 1,1,1,2,4,3,2,2,-1))^(-1)*(matrix(3,1, 21,64,0)) = (matrix(3,3,5/3,-1/2,1/6, -4/3, 1/2, 1/6, 2/3, 0, -1/3))*(matrix(3,1, 21,64,0)) = (matrix(3,1, 3,4,14))}}}.


The number of each type of cake bought is now clear.