Unformatted text preview: % error exit % else compute shipping weight % - standard charge % - overweight charge % print results % caution: a bug lurks here :-) clear % initialize parameters baseRate = 10; baseWeight = 2; maxStandardWeight = 70; additional = 3.75; overweight = 10; o % read and validate weight weight = input('Enter package weight(lb.): '); if isempty(weight) disp('you MUST enter a weight!') elseif weight > 100 disp(['weight of ', num2str(weight), ' exceeds 100 pounds - please see Federal Express.']) % compute shipping cost else % standard package cost = baseRate + ceil(weight-baseWeight)*additional; % overweight charge if (weight > maxStandardWeight) cost = cost + overweight; end end % print results disp(['total shipping cost for ', num2str(weight), ' pounds is $', num2str(cost)]);...
View Full Document
This note was uploaded on 04/05/2010 for the course CHEMENG 05078870 taught by Professor Mustafa during the Spring '10 term at Ege Üniversitesi.
- Spring '10