I do not think this exercise is correct. As one should not put frosting below the cake, the area of the cake to put frost on is the area of the circle on top of it plus the area of the "bent" rectangle on its sides. Thus:
function SA = func_frosting2(r,h)
ARectangle = pi*r*h;
ACircle = pi*r^2;
SA = ARectangle + ACircle;
I think the current solution is misleading
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
r = 3;
h = 2;
y_correct = 65.9734;
assert(abs(func_frosting(r,h) - y_correct) < 1e-4)
SA =
65.9734
|
2 | Pass |
r = 0.5;
h = 0.25;
y_correct = 1.5708;
assert(abs(func_frosting(r,h) - y_correct) < 1e-4)
SA =
1.5708
|
732 Solvers
1900 Solvers
376 Solvers
185 Solvers
1160 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!