title: Bowling score calculator MATLAB
body: <p>Having a slight problem with my bowling score calculator. I'm just a little bit off here and I'm fairly sure it has to do with the last frame. I don't know though.
  A little bit about the loaded variable.
  bowling.xls contains data for 50 games of bowling, so games is a 50x21 matrix.
  The 21 columns correspond with each ball thrown. 
  Thank you guys for any help. If you do not know Matlab, you're welcome to respond in universal code.</p>
  
  <p>EDIT: Here is my up to date code. As you can see the "current" variable is now being preset to show the game I am trying to calculate, so you guys can see it for debugging purposes. The output I am getting from this program is 158. It should be 194.</p>
  
  <pre><code>i = 1;
  gamescore = 0;
  current =  [10 0 6 0 9 1 10 0 10 0 8 2 8 2 8 0 10 0 10 10 10]
  strikes = zeros(1,10);
  spares = zeros(1,10);
  
  % Check for strikes
  for j=1:10
      if current(2*j-1) == 10
          strikes(j) = 1;
      end
  end
  
  % Check for spares
  for j=1:10
      if (current(2*j-1) + current(2*j) == 10) &amp;&amp; (current(2*j-1)~=10)
          spares(j) = 1;
      end
  end
  
  % Calculate score
  for j=1:10
      if strikes(j) == 1
          gamescore = gamescore + 10 + current(2*j) + current(2*j+1);
      elseif spares(j) == 1
          gamescore = gamescore + 10 + current(2*j);
      else
          gamescore = gamescore + current(2*j-1) + current(2*j);
      end
  end
  fprintf('Game score: %d \n',gamescore)
  </code></pre>