Each week a builder makes an order of doors from a supplier. The doors normally cost $60 each, but the supplier gives a 10% discount for any order of 30 or more doors. The orders for the first 8 weeks of the year are given in the vector: orders = [20 40 15 30 25 45 10 35]
% part a
orders = [20 40 15 30 25 45 10 35];
cost = 0;
for index = 1:8 % looping through each order
% 10% discount over 30 orders
if orders(index) >= 30
cost += orders(index)*60*0.9;
% normal price
else
cost += orders(index)*60;
end
end
% printig cost
cost
% part b
weeks = find(orders >= 30)
Comments
Leave a comment