write matlab code to implement differential length, area and volume with values from user?
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
Comments
Leave a comment