This preview shows page 1. Sign up to view the full content.
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
- Spring '10