% manyFrogs.m
% Demonstrates For and While loops, and some control statements

keepGoing = true; 

% as long as the expression keepGoing is true, 
% the While loop will keep repeating the 
% enclosed section of code. 
while keepGoing
    f = input('How many frogs? '); 
    
    if f < 0
        fprintf('That is just silly\n'); 
        break %instantly exits the loop
    elseif f > 10
        fprintf('That is too many frogs for me\n'); 
        continue % returns to the top of the loop, 
                 % including checking 'keepGoing' 
    elseif f == 6
        fprintf('That is my favorite number!\n');
        keepGoing = false; % finishes off the loop, but
                           % will not repeat again since
                           % the expression is now false.
    end
    
    
    % this part will not get run if we hit
    % 'break' or 'continue', but will still run
    % otherwise. 
    for i = 1:f
        fprintf('frog\n'); 
    end
    
    
end