Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Matlab Only Write a function called bowlingScore that takes two input variables: pinsKnockedDown, which is a 10x2 matrix of integers between 0 and 10

Use Matlab Only

Write a function called bowlingScore that takes two input variables: pinsKnockedDown, which is a 10x2 matrix of integers between 0 and 10 indicating the number of bowling pins a player knocked down on each of the two frames of a ten-round game, and bonusPins, which is a single integer that indicates the number of pins knocked down on the final bonus frame. bowlingScore should return a single output variable score that indicates the total score the player earned. On each frame, players earn one point for each pin knocked over. In addition if a player knocks over all ten pins on the first frame of a round (i.e. pinsKnockedDown(i,2)==10), this is called a strike, and the player earns a point for each pin knocked over plus the number of pins knocked over on the following two frames! If a player does not get a strike, but manages to knock over all ten pins by the second frame of a round (i.e. sum(pinsKnockedDown(i,:))==10) then this is called a spare, and the player earns a point for each pin knocked over plus the number of pins knocked over on the next following frame. The bonus frame is only applied if the player earns a strike or a spare on the final tenth round.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

Students also viewed these Databases questions