callPitch

Category: Programming
Author: Brett Wortzman
Book Chapter: 4.2
Problem: callPitch
In a baseball game, the home plate umpire is responsible for calling each pitch either a ball or a strike. A strike is a pitch that crosses home plate in the strike zone and a ball is a pitch that is outside the strike zone when it crosses home plate. The umpire determines whether or not the pitch crossed home plate in the strike zone and calls a strike if so or a ball if not. If a batter gets three strikes, he is out. If he gets four balls, he is awarded first base.

However, umpires prefer the number of balls and strikes to be close to even and will sometimes call pitches incorrectly to achieve this. Umpires call pitches based on the following rules:
    If there is one ball, there is a 1 in 10 chance that an umpire will incorrectly call a pitch that was not in the strike zone a strike.
    If there are two balls, there is a 2 in 10 chance of this. If there are three balls, there is a 3 in 10 chance.
    If there is one strike, there is a 1 in 6 chance that an umpire will incorrectly call a pitch that was in the strike zone a ball.
    If there are two strikes, there is a 2 in 6 chance of this.
    If there are three balls and two strikes (known as a full count), there will only be one more pitch, so the umpire will always call the pitch correctly.

Write a static method named callPitch that takes three parameters: a boolean indicating whether or not the pitch was in the strike zone, and two integers indicating the number of balls and strikes. The method prints "Strike!" if the umpire calls the pitch a strike and "Ball!" if the umpire calls the pitch a ball. The method returns true if the umpire called the pitch correctly and false if not.