MATLAB: Make a matlab of this question

calculationdiscountifmathMATLABswitch

I'm trying to make matllab that can calculate a discount from this number to this number but i forgot about the code. i've only got until here, if there is some mistake do correct me.
clc
fprintf('Calculation of discounts')
fprintf('\n')
#promt user
nam = input('Enter name: ', 's');
adrs = input('Enter address: ', 's');
num = input('Enter amount of purchase: $');
pur = input('Enter type of purchase (L for Laptop / D for Desktop): ', 's');
fprintf('\n')
switch pur
case {'L' 'l'}
fprintf('You have choosen Laptop as your type of puchase')
fprintf('\n')
if num >0
disc = (0 / 100) * num;
net = num - disc;
elseif num >250
disc = (0.05/100)*num;
net = num - disc;
elseif num >570
disc = (0.075/100)*num;
net = num - disc;
elseif num >1000
disc = (0.1/100)*num;
net = num - disc;
end
fprintf('Name: %d\n', nam)
fprintf('Address: %d\n', adrs)
fprintf('Net amount: $%.2f \n', net)
case {'D' 'd'}
fprintf('You have choosen Desktop as your type of purchase')
if num <250
endif
otherwise
fprintf('Invalid type of purchase.')
endswitch

Best Answer

fprintf('Name: %s\n', nam)
fprintf('Address: %s\n', adrs)
and
if num <250
end
Related Question