i know about 'if' code, but what i dont understand is why it tells me error?
error: 'y' undefined near line 33 column 16
error: called from
Code_6 at line 33 column 5
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'} disp('You have choosen Laptop as your type of puchase') if num <250 disc = (0 / 100) * num; net = num - disc; elseif num <570 disc = (5 / 100) * num; net = num - disc; elseif num <1000 disc = (7.5 / 100) * num; net = num - disc; elseif num >1000 disc = (10 / 100) * num; net = num - disc; endif fprintf('Name: %s\n', nam) fprintf('Address: %s\n', adrs) fprintf('Net amount: $%.2f \n', net) #promt user to continue or not yesno = input('Do you wish to continue purchase? (y/n)', 's') fprintf('\n') if yesno = y; Code_6 else disp('You have exit purchase screen, Goodbye.') endif
Best Answer