Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear, clc
- for j=1:3
- service=input('Please input your preferred service type. Ground, Express, or Overnight: ');
- w=input('Please enter the package weight as [lb oz]: ');
- service=lower(service);
- wt=w(1)+w(2)/16;
- switch service
- case 'ground'
- if wt<0.5
- cost=.7+.06*w(2);
- elseif wt<5
- u=ceil(2*(wt-0.5));
- cost=1.18+0.42*u;
- else
- cost=4.96+0.72*ceil(wt-5);
- end
- case 'express'
- if wt<0.5
- cost=2.4+0.25*w(2);
- elseif wt<5
- u=ceil(2*(wt-0.5));
- cost=4.4+1.2*u;
- else
- cost=15.2+1.8*ceil(wt-5);
- end
- case 'overnight'
- if wt<0.5
- cost=12.2+0.8*w(2);
- elseif wt<5
- u=ceil(2*(wt-0.5));
- cost=18.6+4.8*u;
- else
- cost=61.8+6.4*ceil(wt-5);
- end
- end
- fprintf('\nThe cost of service will be $%.2f\n\n',cost)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement