% Menu Example
% Writtenby John Bell for CS 109 Fall 2009

while ( true )
    
    choice = menu( 'Which way ? ', 'North', 'South', 'Easet', 'Quit' );
    
    switch( choice )
        
        
        case 1
            disp( 'It is COOOLD up north! ' );
            
        case 2
            disp( 'Aaaah, nice and warm down south ! ' );
            
        case 4
            break % out of the while loop
            
        otherwise
            disp( 'IMPOSSIBLE! You can''t get there from here' );
        
    end % switch
    
end % while true

disp( 'That was fun !' );

% The following illustrates two means of using loops to check input:

m = -1;
while( m < 1 || m > 12 )
    m = input( 'Please enter a month from 1 to 12 > ' );
    if ( m < 1 || m > 12 )
        disp( [ 'I''m sorry, ', num2str(m), ' is not a valid month.' ] );
    end
    
end
disp( [ 'Thank you, ', num2str( m), ' is a FINE month! ' ] );

daysinmonth = [ 31 29 31 30 31 30 31 31 30 31 30 31 ];
while( true )
    d = input( 'Please enter the day of the month > ' );
    if( d > 0 && d <= daysinmonth( m ) ) 
        break;
    end
    disp( 'I''m sorry, that is a bad day.' );
end
    