Question #185689

write matlab code to implement differential length, area and volume with values from user?


1
Expert's answer
2021-04-29T07:29:26-0400

clc clear fprintf('This program will determine the surface area and volume of a right circular cone,\na cylinder, and a rectangular prism. \n \n');

a = 1;

while a == 1 n = input('How many objects would you like to find the surface area and volume of? ');

shape = input('Enter type of shape (enter cone for right circular cone, cylinder for cylinder,\nrectangle for rectangular prism) : ');

if shape == 'cone' r = ('input radius: ');

h = ('input height: ');

V = π×r2×h3\pi \times r^2 \times \frac{h}{3} ;

SA=πr(r+(h2+r2)5)SA = \pi r(r+(h^2+r^2)^5) ;

disp('Volume = ') disp(V) disp('Surface Area = ') disp(SA);

else if shape == 'cylinder \n' r = ('input radius');

h = ('input hieght');

V = πr2h\pi r^2h ;

SA =2πrh+2πr22 \pi rh+2 \pi r^2 ;

disp('Volume = ') disp(V) disp('Surface Area = ') disp(SA) else if shape == 'rectangle' l = ('input length');

w = ('input width'); h= ('input hieght');

V=wlhwlh ;

SA = 2(wl+hl+hw)2(wl+hl+hw) ;

disp('Volume = ') disp(V) disp('Surface Area = ') disp(SA) end end end a = input('do you want to continue ? 0 for no, 1 for yes');

if a == 0 end end


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS