clc clear all w=input('Enter the width: '); if w<=0 disp ('distance must be positive') break end a=input('Enter the unit (I for inch, C for cm) :','s'); if a=='I' w=w/2.54; elseif a=='C' w=w; else disp (['Unknown units: ', a]) break end l=input('Enter the length: '); if l<=0 disp ('distance must be positive') break end a=input('Enter the unit (I for inch, C for cm) :','s'); if a=='I' l=l/2.54; elseif a=='C' l=l; else disp (['Unknown units: ', a]) break end h=input('Enter the height: '); if h<=0 disp ('distance must be positive') break end a=input('Enter the unit (I for inch, C for cm) :','s'); if a=='I' h=h/2.54; elseif a=='C' h=h; else disp (['Unknown units: ', a]) break end v=(h*l*w)/3; vin=v*2.54^3; disp(['The volume of the pyramid is ',num2str(v), ' cm^3 or ',num2str(vin), ' in^3'])
|