Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.07 KB | None | 0 0
  1. clear, clc
  2. for j=1:3
  3.     service=input('Please input your preferred service type. Ground, Express, or Overnight: ');
  4.     w=input('Please enter the package weight as [lb oz]: ');
  5.     service=lower(service);
  6.     wt=w(1)+w(2)/16;
  7.     switch service
  8.         case 'ground'
  9.             if wt<0.5
  10.                 cost=.7+.06*w(2);
  11.             elseif wt<5
  12.                 u=ceil(2*(wt-0.5));
  13.                 cost=1.18+0.42*u;
  14.             else
  15.                 cost=4.96+0.72*ceil(wt-5);
  16.             end
  17.         case 'express'
  18.             if wt<0.5
  19.                 cost=2.4+0.25*w(2);
  20.             elseif wt<5
  21.                 u=ceil(2*(wt-0.5));
  22.                 cost=4.4+1.2*u;
  23.             else
  24.                 cost=15.2+1.8*ceil(wt-5);
  25.             end
  26.         case 'overnight'
  27.             if wt<0.5
  28.                 cost=12.2+0.8*w(2);
  29.             elseif wt<5
  30.                 u=ceil(2*(wt-0.5));
  31.                 cost=18.6+4.8*u;
  32.             else
  33.                 cost=61.8+6.4*ceil(wt-5);
  34.             end
  35.     end
  36.     fprintf('\nThe cost of service will be $%.2f\n\n',cost)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement