User`s manual
5 Calling Java from MATLAB
5-76
6. Display the Action Menu and Get the User’s Selection
Within a while loop, several disp statements display a menu of actions that 
the user can perform on the phone book. Then, an 
input statement requests the 
user’s typed selection.
while 1
 disp ' '
 disp ' Phonebook Menu:'
 disp ' '
 disp ' 1. Look up a phone number'
 disp ' 2. Add an entry to the phone book'
 disp ' 3. Remove an entry from the phone book'
 disp ' 4. Change the contents of an entry in the phone book'
 disp ' 5. Display entire contents of the phone book'
 disp ' 6. Exit this program'
 disp ' '
 s = input('Please type the number for a menu selection: ','s');
7. Invoke the Function to Perform A Phone Book Action
Still within the while loop, a switch statement provides a case to handle each 
user selection. Each of the first five cases invokes the function to perform a 
phone book action.
Case 1 prompts for a name that is a key to an entry. It calls 
isempty to 
determine whether the user has entered a name. If a name has not been 
entered, it calls 
disp to display an error message. If a name has been input, it 
passes it to 
pb_lookup. The pb_lookup routine looks up the entry and, if it finds 
it, displays the entry contents.
switch s
 case '1',
 name = input('Enter the name to look up: ','s');
 if isempty(name)
 disp 'No name entered'
 else
 pb_lookup(pb_htable, name);
 end;










