Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Buttar bot\'s sole purpose was once to pass butter across the dining room table

ID: 3755395 • Letter: B

Question

Buttar bot's sole purpose was once to pass butter across the dining room table Now we are upgrading it to put the correct amount of butter on a piece of toast Write a nction called houMuchButter for Butter Bot to do this. It should talce two guts. -toastThichness, the thicimess of the toast slice in inches - toastarea, the area of the slice of toast in square inches It should return one outun, buteinsunt This output should be The string r mall amount of butter-ifthe toast thicmess is less than 0.5 inches AND the toast area is less than9 square inches sqpared - If a small amount was not added the suing Hoderate amount o butter' if the toast thiclness is beween (and including 05 and0.75 ches AND thetost area is betveen (and inchuding) 9 and 16 inches squared -If a moderate amount was not added. te str ng . Lots of butter ' ifte toast thickness is greater than 0.75 inches AND the toast area is greater than 16 inches squared In all other cases, return, shape of toet too treird

Explanation / Answer

%{

This is howMuchButter function which takes toast thickness and toast area and outputs amount of butter.

Basically, it check toastThickness and toastArea for the conditions as mentioned in question.

%}

function f = howMuchButter(toastThickness, toastArea)

if (toastThickness < 0.5) && (toastArea < 9)

disp('Small amount of butter')

elseif (toastThickness >= 0.5 && toastThickness<=0.75) && (toastArea >= 9 && toastArea <=16)

disp('Moderate amount of butter')

elseif (toastThickness > 0.75) && (toastArea > 16)

disp('Lots of butter')

else

disp('Shape of toast too weird')

end

end