Uploaded by johannie uka

PExer03 Code 1 version 1

advertisement
disp('Menu')
disp('1. Cylinder')
disp('2. Circle')
disp('3. Rectangle')
S = input('Please choose one: ');
if S == 1
R = input('Enter the radius of the cylinder: ');
H = input('Enter the height: ');
fprintf('The surface area is: %.2f', 2*pi*R*H)
elseif S == 2
R = input('Enter the radius of the circle: ');
fprintf('The area is: %.2f\n',pi*R*R)
elseif S == 3
L = input('Enter the length: ');
W = input('Enter the width: ');
fprintf('The area is: %.2f\n',L*W)
else
fprintf('Error!')
end
Download