price=input('price:');
num=fix(price/500);
switch num
    case 0                  %总价小于500
        rate=0;             
    case 1                  %总价大于等于500，小于1000
        rate=5/100;            
    case {2,3}               %总价大于等于1000，小于2000
        rate=10/100;
    case num2cell(4:9)       %总价大于等于2000，小于5000
        rate=15/100;
    otherwise                %总价大于等于5000   
        rate=20/100;
end
discount_price=price*(1-rate)  %折扣后的总价
format short g                 %不用科学计数显示 

