Matlab question 3 In-class Exercise 3. You have been contacted by a construction
ID: 3911600 • Letter: M
Question
Matlab question 3
In-class Exercise 3. You have been contacted by a construction agency that wants you to develop a program to calculate the total surface area of several identical boxes. The construction agency wants all of the formula used for the calculations to be inside functions so that their employees can easily troubleshoot the code. The code should also have a friendly' interface (submit you solution as a SEPARATE script file named lastname_firstname_construction.m) Requirements a) b) c) d) e) Ask the user for the dimensions required to calculate the surface area of box Ask the user for the number of boxes Calculate and display the total surface area of all boxes Ensure all calculations take place inside a function Ensure the code is well documentedExplanation / Answer
Please find the required function in MATLAB. The function is called by its name only i.e. no argumetns has to be passed. Simply type last lastname_firstname_construction and hit enter in the command line.
The function is named "lastname_firstname_construction". If you are modifying the name of the function, you must modify the name of the file accordingly so that they match.
%===============================================
function [ ] = lastname_firstname_construction( )
% Acquiring user input
length = input('Please provide the length of the box: ');
width = input('Please provide the width of the box: ');
height = input('Please provide the height of the box: ');
box_count = input('Please provide the number of identical boxes: ');
% There are total 6 surfaces in a box form from the combination of
% length x width | width x height | height x lenght
% Each surface combination is having 2 such surfaces
% Hence the total surface are for a box is:
* (length*width + width*height + height*length);
% Hence total surface are for all the boxes is:
total_box_area = box_count * one_box_area;
fprintf(' The total surface area of all the boxes is: %f ',total_box_area);
end
%============================================
Sample output:
>> lastname_firstname_construction
Please provide the length of the box: 5
Please provide the width of the box: 4
Please provide the height of the box: 3
Please provide the number of identical boxes: 3
The total surface area of all the boxes is: 282.000000
Hope this helps! ******** Please Thumbs Up ********
In case of any clarification required, please comment.