0% found this document useful (0 votes)
27 views

Part 1

This MATLAB function calculates the paint required and material cost for a cylinder. It takes the radius (r) and height (h) as inputs, uses them to determine the volume and surface area of the cylinder, then calculates that the paint required is the volume in liters and the material cost is the surface area multiplied by $3 per square meter. The results are printed out.

Uploaded by

Mujtaba Hussein
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Part 1

This MATLAB function calculates the paint required and material cost for a cylinder. It takes the radius (r) and height (h) as inputs, uses them to determine the volume and surface area of the cylinder, then calculates that the paint required is the volume in liters and the material cost is the surface area multiplied by $3 per square meter. The results are printed out.

Uploaded by

Mujtaba Hussein
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

10/7/17 12:39 AM C:\Users\Mujtaba\Desktop\To Do...\part1.

m 1 of 1

function [ ] = part1(r,h)
% Homework 3.2 part 1
% a. Paint required
% r and h are in meters
V = pi*h*r^2; % Volume of cylinder
A = 2*pi*r*h + 2*pi*r^2; % surface area of cylinder
% calculates material cost. Assumed alumunium costs $3 per m^2
cost = 3*A; % cost in dollars
paint = V*1000; % paint required in liter
fprintf('Paint Required is %f liters\n',paint)
fprintf('Cost of material is $%f \n', cost)
end

You might also like