% -----------------------------------------------------
% hurricane_category.m
% -----------------------------------------------------
% Hurricanes are categorized based on wind speeds. Write a script that
% will prompt the user for the wind speed and will display the hurricane 
% category number and the typical storm surge.   
% -----------------------------------------------------
% Notes: None. 
% -----------------------------------------------------
% Copyright and license details available at matlabmarina.com
%------------------------------------------------------

% Clear all variables and clear the command window
clear
clc

% Ask user to input the wind speed in mph
windspeed = input('Type in the wind speed in mph   ');
% Round off the windspeed to the nearest integer 
windspeed = round(windspeed);

% Conditional statements used to evaluate the category and storm surge
if windspeed <= 0
    error('Please input a positive value of wind speed');
elseif 1 <= windspeed && windspeed <= 73  % elseif is one word   
    error('Please input a wind speed >= 74 mph');
elseif 74 <= windspeed && windspeed <= 95  
    % 2 or more conditions can be defined using && or || as applicable
    hcat = 1;
    stormsurge = '4-5';       % storm surge is a given range
elseif 96 <= windspeed && windspeed <= 110  
    hcat = 2;
    stormsurge = '6-8';
elseif 111 <= windspeed && windspeed <= 130
    hcat = 3;
    stormsurge = '9-12';
elseif 131 <= windspeed && windspeed <= 155
    hcat = 4;
    stormsurge = '13-18';
else % Note that else implies all other conditions were false.
    % There is no other condition associated with else.
    hcat = 5;
    stormsurge = '>18';
end % All conditional statements must be 'closed' with an end.
    
% Display outputs - hurricane category and storm surge
disp('The hurricane category');  disp(hcat);
disp('The storm surge');  disp(stormsurge);
