MATLAB: My code works except variable s remains fixed to 20 when it should be changing depending on the values of input for variable x

beginnerhomeworknoob

Can someone help me with my code? I'm trying to calculate the cost (x), taxes (t), and shipping cost (s) but for some reason the shipping doesn't change with the parameters I put.
prompt='How many giant slinkys do u wanna buy? ';
x=input(prompt);
if x<=10;
x= 21.99*x;
elseif (11>=x)&(x<=50);
x=x*19.99;
elseif (51>=x)&(x<=100);
x= x*17.99;
else x >= 100;
x= x*15;
end
if x<=10;
s=10;
elseif (x>10)&(x<=20);
s=20;
elseif (x>20)&(x<=30);
s=30;
elseif (x>30)&(x<=40);
s=40;
elseif (x>40)&(x<=49);
s=50;
elseif (x>=50);
s=0;
end
disp('Cost will be ')
disp(x);
t=x+.095*x;
disp('sales tax')
disp(t);
disp('Shipping cost')
disp(s);
T=x+t+s;
disp('The total cost is')
disp(T)

Best Answer

The value of x will have been changed by your first decision structure, so by the time you test it again in the second decision tree it will be much higher than it was originally since you have already scaled it up by a factor. I suspect that this isn't intentional and instead of changing x you want to reassign x to a new variable.