function name = state_name_from_index ( index )

%*****************************************************************************80
%
%% state_name_from_index() returns the name of a given US state.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 October 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer index: the state index, between 1 and 50.
%
%  Output:
%
%    character name(): the state name.  
%
  id_array = { ...
    'Alabama', ...
    'Alaska', ...
    'Arizona', ...
    'Arkansas', ...
    'California', ...
    'Colorado', ...
    'Connecticut', ...
    'Delaware', ...
    'Florida', ...
    'Georgia', ...
    'Hawaii', ...
    'Idaho', ...
    'Illinois', ...
    'Indiana', ...
    'Iowa', ...
    'Kansas', ...
    'Kentucky', ...
    'Louisiana', ...
    'Maine', ...
    'Maryland', ...
    'Massachusetts', ...
    'Michigan', ...
    'Minnesota', ...
    'Mississippi', ...
    'Missouri', ...
    'Montana', ...
    'Nebraska', ...
    'Nevada', ...
    'New Hampshire', ...
    'New Jersey', ...
    'New Mexico', ...
    'New York', ...
    'North Carolina', ...
    'North Dakota', ...
    'Ohio', ...
    'Oklahoma', ...
    'Oregon', ...
    'Pennsylvania', ...
    'Rhode Island', ...
    'South Carolina', ...
    'South Dakota', ...
    'Tennessee', ...
    'Texas', ...
    'Utah', ...
    'Vermont', ...
    'Virginia', ...
    'Washington', ...
    'West Virginia', ...
    'Wisconsin', ...
    'Wyoming' };

  if ( index < 1 || 50 < index )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'state_name_from_index(): Fatal error!' );
    fprintf ( 1, '  Illegal index value = %d', index );
    error ( 'state_name_from_index(): Illegal index value.' );
  end

  name = char ( id_array( index ) );

  return
end

