Part 1. Create the flow chart and a single MATLAB script that: Tells the user th
ID: 3806198 • Letter: P
Question
Part 1.
Create the flow chart and a single MATLAB script that:
Tells the user that this is a program which will determine the surface area and volume of three different types of solid objects: a hemisphere, a cylinder, and a rectangular box (assume the box can have a different width, depth and height).
Asks the user for how many objects they want to find the surface area and the volume.
Prompts the user for the type of object and then prompts the user for appropriate geometric inputs such as width, height, depth, and radius.
Outputs the results of calculating the surface area and the volume of the objects to the screen.
Informs the user when it has completed the requested number of calculations, and asks the user if they would like to run the program again.
Note: assume the cylinder is a solid right circular cylinder, and include the surface area of the bottom of the hemisphere.
Sample run: 3 objects, hemisphere, cylinder and box. Parameters:
Hemisphere—Radius = 5cm
Cylinder –Radius = 5cm, height = 5cm
Box—length = 2cm, width = 3cm, depth = 5cm
Explanation / Answer
print('This program will determine the surface area and volume of three different types of solid objects')
pi=3.14
ch=1
while (ch=1) do
n=int(input('Enter the number of objects'))
for i=0 : n
type=input('Enter the type of object: ')
if type =='Hemisphere' then
r=int(input('Radius ='))
fprintf('Hemisphere—Radius = %d cm',r);
fprintf('Volume = %f ',abs((2/3)*pi*r));
fprintf('Surface area = %f ',abs(4*pi*r*r));
elseif type =='Cylinder' then
r=int(input('Radius ='))
h=int(input('Height ='))
fprintf('Cylinder—Radius = %d cm , height = %d cm',r,h);
fprintf('Volume = %f ',abs(pi*r*r*h));
fprintf('Surface area = %f ',abs(2*pi*r*h+2*pi*r*r))
elseif type =='Box' then
l=int(input('Length ='))
w=int(input('width ='))
h=int(input('height ='))
fprintf('Box—Length = %d cm , width = %d cm height = %d cm',l,w,h)
fprintf('Volume = %d ',w*h*l);
fprintf('Surface area = %d ',2(w*l + h*l+ h*w))
end
ch=int(input('Do you want to continue ? <0 / 1>'))
if(ch=0)
break
end
end