For the case as stated below,
a=3; b=4; c=5;
k = menu ('choose','a','b','c');
If the user select a how can I assign a value for it and do a logical loop? For example,
if 'a'; x=a;
else if 'b'; x=b;
else if 'c'; x=c;
end
Then I can continue my calculation using the value of x assigned. For example,
w=x+5
k is the number of the user's choice. In your case:
switch (k)
case 1
x = a;
case 2
x = b;
case 3
x = c;
otherwise
fprintf(1, 'do not know what to do - user closed menu w/o selection\n');
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With