% Prompt user for input string
str = input('Please enter a string: ', 's');
% call of the function
[stringLength, firstLetter, lastLetter, reverse] = baker6(str);
% displays the menu and determines what option the user wants
list = fprintf('Please choose an option: \n 1. Length \n 2. First Letter \n 3. Last Letter \n 4. Reverse \n 5. All \n 6. Enter a new string \n 7. Quit');
menu = input(' \n Choice: ');
switch(menu)
case {1}
fprintf('The length of %s is %.0f ' ,str, baker6(stringLength));
case {2}
sprintf('The first letter of %c is %c ' ,str, baker6(firstLetter));
case {3}
sprintf('The last letter of %s is %s ' ,str, baker6(lastLetter))
case {4}
sprintf('The reverse of %s is ' , str, baker6(reverse))
case {5}
disp('Hello')
case {6}
str = input('Please enter a new string: ' , 's');
case {7}
query = input('Are you sure you would like to quit? (Yes/No) ');
otherwise
disp(list)
end
This post has been edited by Epic800: 03 October 2012 - 04:44 PM

New Topic/Question
Reply



MultiQuote







|