%
% A08B.m
%
% User picks a number between 1 and 10 and trie to match a
% randomly-generated number picked by the computer.
%
% Programming Concepts:  if statement, random number generator
%                           remainder function rem()
%
% INPUT:    User is prompted to enter a number between 1 and 10
% OUTPUT:   The computer tells the user if he/she is a lucky winner
%
% Matlab-Monkey.com
% 12/30/2014

% tidy-up your workspace
clc         % clear command window
clear       % clear all variables
close all   % close all graphics windows

% get number from user
N = input('Pick an integer between 1 and 10:  ');

% check to see if the number is an integer between 1 and 10
% if it is, then test it against a randomly-generated number
if N <1 | N > 10
    disp('your number needs to be between 1 and 10')
    disp ('try again')

elseif rem(N,1) ~= 0            % the ~= symbol means "not equal"
                                % the rem(a,b) function returns the
                                % remainder of a/b
    disp ('your number is not an integer')
    disp ('try again')
    
else
    % computer picks a random number between 1 and 10
    M = randi(10);

    % if the numbers match, the user wins!
    if N == M
        disp('you win :)')
    else
        disp('you lose :(')
    end
end