function y = yearbattingaverage(n)
%This function file computes Tony's batting average for
%a single year, by simulating n at bats, adding up the 
%number of hits, and then dividing by n.
X=zeros(1,n);
for i = 1:n
    atbat;
    X(i)=r;
end
y=sum(X)/n;
