MATLAB: Using input statement to test elseif

elseifhomeworkinput statement

How do I use the input statement to test my elseif code.
Here is my code:
if y<10000
t=200;
elseif 10000<y<20000
t=200+0.1*(y-10000);
elseif 20000<y<50000
t=1200+0.15*(y-20000);
elseif y>50000
t=5700+0.25*(y-50000);
end
thanks for the help

Best Answer

try this. Also, correct the conditions with elseif blocks. In MATLAB 20000<y<50000 does not mean what you probably think it means
y = input('Enter value of y: ');
if y<10000
t=200;
elseif 10000<y && y<20000 % correct condition

t=200+0.1*(y-10000);
elseif 20000<y && y<50000 % correct condition
t=1200+0.15*(y-20000);
elseif y>50000
t=5700+0.25*(y-50000);
end
fprintf('%.2f\n', t);