A painting company has determined that for every 115 square feet of wall space,
ID: 441422 • Letter: A
Question
A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor are required. The company charges $18 per hour of labor. Write a MATLAB function that has as input arguments: 1) an array with the square footage of each room to be painted, 2) price per gallon of paint. The program will print out to the screen, in complete sentences, the following information: the number of gallons of paint required & the cost of the paint, the hours of labor required & the labor charges, and the total cost of the paint job. For example: paintjob([400,500,360] ,22) Number of gallons = 11; total cost of paint = $242.00 Hours of labor = 88.0; labor cost = $1584.00 Total cost = $1826.00 Use fprintf to print the results. Do not use sum; use a for-loop to solve this problem.Explanation / Answer
%PLEASE RATE, and if anyone copys answer , please Flag them
function paintjob(sqfootage,price)
% every 115sqft = 1gal paint && 8hr
hourRate=18; % cost per hour of labor
area=0;
for i=1:length(sqfootage)
area=area+sqfootage(i);
end
gal=ceil(area/115);% one gallon =115 sqft , round ups
hours=gal*8;% total hours
paintCost=price*gal;
LaborCost=hourRate*hours;
TotalCost=paintCost+LaborCost;
fprintf('Number of labor = %d; total cost of paint = $%.2f ',gal,paintCost);
fprintf('Hours of labor = %.1f; labor cost = $%.2f ',hours,LaborCost);
fprintf('Total cost = $%.2f ',TotalCost);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.