Answer to Question #185689 in Electricity and Magnetism for Rahul

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 = "\\pi \\times r^2 \\times \\frac{h}{3}" ;

"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 = "\\pi r^2h" ;

SA ="2 \\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="wlh" ;

SA = "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!

Leave a comment

LATEST TUTORIALS
New on Blog