%------------------------------------------------------------------------------
% Write a program that checks if a value is "close" to another.
%
% Pretend that you have 2 values, x and y that are close, meaning
% that if you subtracted one from the other, you would get a very
% small value. We call that value epsilon (eps):
%
%                  x  y
%        <---------+--+---------> number line
%               -->|  |<-- eps
%
% To test if x is close to y, you would check if the following
% works:
%            y-x <= eps
%
% Since we do not know whether or not you mean x-y or y-x, use
% absolute value to check the difference between x and y: 
%
%            abs(x-y) <= eps
%
% Note 1: Why bother with all of this?                  _
% Think about 1/3 vs its decimal value, which is 0.3333.
% If you compre 1/3 with that decimal value using $==$, MATLAB will
% *NOT* succeed. So, you need a value of EPS to account for
% roundoff error.
%
% Note 2: You can use MATLAB's default EPS or assign a new value to it.
%------------------------------------------------------------------------------
% MATLAB PROGRAM

  % Clean things up:
    clear;clc;
  
  % Obtain two values to check:  
    disp('You will check if two values are close to being "same."');
    testValue1 = input('Enter a number: ');
    testValue2 = input('Enter another number: ');

  % Prompt the user to determine EPS:
    disp('You need to chose an eps.');
    choice=input('Do you wish to use built-in EPS? Choose [y,n]: ','s');
    if choice=='n'
      eps=input('Enter an eps: ');
    elseif choice=='y'
      disp('Using built-in EPS...');
    else
      disp('I do not recognize that choice!');
    end
	  
  % Compare the values within EPS. Do not process anything if user
  % had entered an illegal choice:
    if choice=='y' | choice=='n'
       if abs(testValue2-testValue1) <= eps
          disp('Congratulations! Your values are about the same!');
       else
          disp('Bummer! Your values are too far apart!');
       end
    else
       disp('Processing not continued!');
    end

%------------------------------------------------------------------------------
