%==============================================================================
% Selection statement examples
%==============================================================================
% Example: Write a program that checks if a user input number 
%          matches a known value.
%
% Algorithm:
% + Store a number
% + Prompt user for a value
% + Check if number matches
% + Report results
 
  clear; clc;
  storedValue = 10;
  testValue = input('Enter a number: ');
  if testValue == storedValue
    disp('Hooray! You got the right value!');
  end
  disp('Press any key to continue....');pause;
%------------------------------------------------------------------------------
% Hmmm... not very friendly as programs go....
% + need to improve output
% + perhaps warn if they don't match?

  clear; clc;
  storedValue = 10;
  testValue = input('Enter a number: ');
  if testValue == storedValue
    disp('Hooray! You got the right value!');
  else
    disp('Whoops! Wrong number!');
  end
  disp('Press any key to continue....');pause;
%------------------------------------------------------------------------------
% Now, what about other values? Perhaps you want to test the sign
% of a number instead, and you don't know about the built-in $sign$ function:  

  clear;clc;
  disp('Welcome to my sign-testing program!');
  testValue = input('Enter a number. I can handle it: ');
  % Test the sign of a number:
    if testValue > 0
      disp('Your number is positive.')
    elseif testValue < 0
      disp('Your number is negative.')
    elseif testValue == 0
      disp('Your number is zero.')
    else
      disp('I cannot analyze that value.');
    end
  disp('Press any key to continue....');pause;
%------------------------------------------------------------------------------
