Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

function [total_surface_area, total_volume] = Sallydron(a, b)

% [total_surface_area, total_volume] = Sallydron(a, b)


% Written by Shehan
% Created on 10/11/2023
%
% Input Arguments
% ------
% a - length of one side of hexagon
% b - length of one rectangle
%
% Outputs
% ------
% total_surface_area - total surface area of the object
% total_volume - total volume of the object
%
% Total surface area = area of 18 rectangular segments + area of 12 hexagonal
segments
% Area of rectangle = a * b
rectangle_area = a * b;

% Area of hexagon = (3 * square root(3) / 2) * a^2


hexagon_area = ((3 * sqrt(3)) / 2) * a^2;

total_surface_area = (rectangle_area * 18) + (hexagon_area * 12)

% Total volume = cross-sectional area * length


cross_sectional_area = (9 * sqrt(3)) * a^2;
total_volume = cross_sectional_area * b
end

You might also like