function count = rollDieV1(rolls)
% Simulate rolling of a fair 6-sided die
% Usage:  count = rollDieV1(rolls)
%   ROLLS is the number of times to roll die
%   COUNT is vector of how many times each outcome occurs
%     count(f) is the number of times face f occurs

FACES= 6;               % number of faces on die
count= zeros(1,FACES);  % bins to store counts

% Count outcomes of rolling a FAIR die
for k= 1:rolls
    % roll the die
    face= ceil(rand(1,1)*FACES);
    % increment appropriate bin
    if face==1
        count(1)= count(1) + 1;
    elseif face==2
        count(2)= count(2) + 1;
    elseif face==3
        count(3)= count(3) + 1;
    elseif face==4
        count(4)= count(4) + 1;
    elseif face==5
        count(5)= count(5) + 1;
    else   % face is 6
        count(6)= count(6) + 1;
    end
end
% Improve the implementation of the loop body!!
% See Lab Exercise 6


% Show histogram of outcome
bar(1:FACES, count);
title(['Outcomes from ' num2str(rolls) ' rolls of fair die']);
xlabel('Outcome');  ylabel('Count');
